erase two element of an array

erase two element of an array

Postby Silvio.Falconi » Mon Mar 23, 2020 11:16 pm

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  Expand view
#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
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: 6897
Joined: Thu Oct 18, 2012 7:17 pm

Re: erase two element of an array

Postby karinha » Tue Mar 24, 2020 1:23 am

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7607
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: erase two element of an array

Postby nageswaragunupudi » Tue Mar 24, 2020 4:04 am

Code: Select all  Expand view
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
nageswaragunupudi
 
Posts: 10465
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: erase two element of an array

Postby Silvio.Falconi » Tue Mar 24, 2020 11:05 am

thanks
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: 6897
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 30 guests