FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Insert an record on array
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Insert an record on array
Posted: Fri Jan 12, 2024 02:54 PM
I have an array of 32 fields that I process with xbrowse.
I need to insert a record between two rows
the first field must be "codsep" field
how can I do ?


TO paste an record of oBrw:aArrayData I use an array aCopy where I save the row Copied (oBrw:aselected) and I use these commands
Code (fw): Select all Collapse
 

oBrw:Lock()
              For n=1 to Len(acopy)
                aCopy[n][1] := codsep
                aCopy[n][32] := 0
                aadd( oBrw:aArrayData, aCopy[n] )
              Next
      oBrw:Unlock( .t. )
but this paste the record at the end of oBrw:aArrayData, How I can to insert all aCopy between two rows
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Insert an record on array
Posted: Fri Jan 12, 2024 03:57 PM
Code (fw): Select all Collapse
HB_AINS( oBrw:aArrayData, nPos, aRow, .T. )
Regards



G. N. Rao.

Hyderabad, India
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: Insert an record on array
Posted: Fri Jan 12, 2024 04:00 PM
nageswaragunupudi wrote:
Code (fw): Select all Collapse
HB_AINS( oBrw:aArrayData, nPos, aRow, .T. )
nPos could be the number of record selected ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Insert an record on array
Posted: Sun Jan 14, 2024 06:11 AM
Dear Silvio,
Arguments
aArray The array name into which the value xValue will be inserted.
nPos Subscript position in aArray. Default: 1st position
xValue Value to be inserted
lAutoSize Boolean flag to increase or not the size of aArray.
Default value: .F.
https://harbour.github.io/doc/harbour.html#hb_ains

example:
Code (fw): Select all Collapse
function Main()

   local a1 := { 1, 2, 3 }
   local a2 := { 4, 5 }

   ? HB_AIns( a1, 2, a2, .T. )

return nil
result:
{1, {4, 5}, 2, 3}
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: Insert an record on array
Posted: Mon Jan 15, 2024 09:03 AM
Antonio Linares wrote:Dear Silvio,
Arguments
aArray The array name into which the value xValue will be inserted.
nPos Subscript position in aArray. Default: 1st position
xValue Value to be inserted
lAutoSize Boolean flag to increase or not the size of aArray.
Default value: .F.
https://harbour.github.io/doc/harbour.html#hb_ains

example:
Code (fw): Select all Collapse
function Main()

   local a1 := { 1, 2, 3 }
   local a2 := { 4, 5 }

   ? HB_AIns( a1, 2, a2, .T. )

return nil
result: {1, {4, 5}, 2, 3}
I have insert a record on multiple array
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com

Continue the discussion