Insert an record on array

Insert an record on array

Postby Silvio.Falconi » Fri Jan 12, 2024 2: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: Select all  Expand view


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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6782
Joined: Thu Oct 18, 2012 7:17 pm

Re: Insert an record on array

Postby nageswaragunupudi » Fri Jan 12, 2024 3:57 pm

Code: Select all  Expand view
HB_AINS( oBrw:aArrayData, nPos, aRow, .T. )
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10250
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Insert an record on array

Postby Silvio.Falconi » Fri Jan 12, 2024 4:00 pm

nageswaragunupudi wrote:
Code: Select all  Expand view
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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6782
Joined: Thu Oct 18, 2012 7:17 pm

Re: Insert an record on array

Postby Antonio Linares » Sun Jan 14, 2024 6: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: Select all  Expand view
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
User avatar
Antonio Linares
Site Admin
 
Posts: 41318
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Insert an record on array

Postby Silvio.Falconi » Mon Jan 15, 2024 9: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: Select all  Expand view
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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6782
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Cgallegoa and 7 guests