erase two element of an array

Post Reply
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

erase two element of an array

Post by Silvio.Falconi »

I have an array


1
1
2
2
3 <------------------ I wish erase this
3 <------------------I wish erase this
4
4
5
5

and I wish erase only the lines having the number 3

I not understood why the procedure erase only one line having the number 3






the test

Code: Select all

#include "Fivewin.ch"

Function test()
   local aItemsRows:={}
   local n,d
local nNumber:=3

// create an array
For n= 1 to 5
      aadd(aItemsRows, {n} )
      aadd(aItemsRows, {n} )
next n


xbrowser aItemsRows

//now I wish erase only some records all numbers 3

For d =1 to Len(aItemsRows)

           IF aItemsRows[d][1]=nNumber
                 adel( aItemsRows,d,.f.)
                //   asize( aItemsRows, len( aItemsRows))
              ENDIF

           next d

xbrowser aItemsRows
return nil
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
User avatar
karinha
Posts: 4882
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: erase two element of an array

Post by karinha »

João Santos - São Paulo - Brasil
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: erase two element of an array

Post by nageswaragunupudi »

Code: Select all

For n= 1 to 5
      aadd(aItemsRows, {n} )
      aadd(aItemsRows, {n} )
next n

xbrowser aItemsRows

n := 1
do while n < Len( aItemsRows )
   if aItemsRows[ n, 1 ] == 3
      ADel( aItemsRows, n, .t. )
   else
      n++
   endif
enddo

xbrowser aItemsRows

 
Regards

G. N. Rao.
Hyderabad, India
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: erase two element of an array

Post by Silvio.Falconi »

thanks
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
Post Reply