ERASE ELEMENT ARRAY

Post Reply
User avatar
Silvio.Falconi
Posts: 7136
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 1 time

ERASE ELEMENT ARRAY

Post by Silvio.Falconi »

I have an array
I wish erase only the element aDataDisposizioni [i][1] empty

I make

AEval( AClone( aDataDisposizioni ), { |a,i| If( empty(a[i])[1], ADel( aDataDisposizioni, n, .t. ), n++ ) } )

give me an error

any solution pls
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
Carlos Mora
Posts: 989
Joined: Thu Nov 24, 2005 3:01 pm
Location: Madrid, España

Re: ERASE ELEMENT ARRAY

Post by Carlos Mora »

Silvio,
what's the value of 'n'?

there is a syntax problem, check empty(a[i])[1] empty(a[i]) ->Boolean may be you mean empty(a[i][1])
Saludos
Carlos Mora
http://harbouradvisor.blogspot.com/
StackOverflow http://stackoverflow.com/users/549761/carlos-mora
“If you think education is expensive, try ignorance"
User avatar
Silvio.Falconi
Posts: 7136
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 1 time

Re: ERASE ELEMENT ARRAY

Post by Silvio.Falconi »

i try also with

FOR i = 1 TO LEN( aDataDisposizioni )
IF empty(aDataDisposizioni[ i, 1 ] )
ADEL( aDataDisposizioni, i )
ASIZE( aDataDisposizioni, LEN( aDataDisposizioni ) - 1 )
ENDIF
NEXT


but not run

I wish erase the blank lines of this array

Image
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
Enrico Maria Giordano
Posts: 8753
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Has thanked: 1 time
Been thanked: 4 times
Contact:

Re: ERASE ELEMENT ARRAY

Post by Enrico Maria Giordano »

Silvio,

build a complete sample showing the problem, please.

EMG
User avatar
Silvio.Falconi
Posts: 7136
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 1 time

Re: ERASE ELEMENT ARRAY

Post by Silvio.Falconi »

to simulate I insert only two teachers
I wish erase the empty lines ( if the first column is empty - when there is not the name of teacher)

sample code

Code: Select all | Expand



#include "FiveWin.ch"

Function Test
Local aDataDisposizioni
local ntotaledocentiDisposizioni:= 65
local nTotalecolonne:=7

aDataDisposizioni := ARRAY(ntotaledocentiDisposizioni,nTotalecolonne)


         
//to simulate the array ( I have with from calculation with a dbf)

                               aDataDisposizioni[3][1] :="teacher 1"
                               aDataDisposizioni[3][2] :="1A"
                               aDataDisposizioni[3][3] :="1C"
                               aDataDisposizioni[3][5] :="1D"
                               aDataDisposizioni[3][6] :="1B"


                               aDataDisposizioni[7][1] :="teacher 2"
                               aDataDisposizioni[7][2] :="4A"
                               aDataDisposizioni[7][3] :="5C"
                               aDataDisposizioni[7][5] :="2D"
                               aDataDisposizioni[7][6] :="3B"


                               xbrowse( aDataDisposizioni )


return nil
 


I wish show only that two lines ... (then I use a xbrowse)
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
Enrico Maria Giordano
Posts: 8753
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Has thanked: 1 time
Been thanked: 4 times
Contact:

Re: ERASE ELEMENT ARRAY

Post by Enrico Maria Giordano »

Silvio,

Code: Select all | Expand

#include "FiveWin.ch"

Function Test
Local aDataDisposizioni
local ntotaledocentiDisposizioni:= 65
local nTotalecolonne:=7
local i

aDataDisposizioni := ARRAY(ntotaledocentiDisposizioni,nTotalecolonne)


         
//to simulate the array ( I have with from calculation with a dbf)

aDataDisposizioni[3][1] :="teacher 1"
aDataDisposizioni[3][2] :="1A"
aDataDisposizioni[3][3] :="1C"
aDataDisposizioni[3][5] :="1D"
aDataDisposizioni[3][6] :="1B"


aDataDisposizioni[7][1] :="teacher 2"
aDataDisposizioni[7][2] :="4A"
aDataDisposizioni[7][3] :="5C"
aDataDisposizioni[7][5] :="2D"
aDataDisposizioni[7][6] :="3B"

for i = 1 to len( aDataDisposizioni )
    if Empty( aDataDisposizioni[ i, 1 ] )
        adel( aDataDisposizioni, i )
        asize( aDataDisposizioni, len( aDataDisposizioni ) - 1 )
        i--     // <-- NOTE
    endif
next


xbrowse( aDataDisposizioni )


return nil


EMG
User avatar
Silvio.Falconi
Posts: 7136
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 1 time

Re: ERASE ELEMENT ARRAY

Post by Silvio.Falconi »

eNRICO,
THANKS
and How I can make to del the array ?
because the user can use this array many times
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
Enrico Maria Giordano
Posts: 8753
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Has thanked: 1 time
Been thanked: 4 times
Contact:

Re: ERASE ELEMENT ARRAY

Post by Enrico Maria Giordano »

Silvio,

Code: Select all | Expand

asize( aDataDisposizioni, 0 )


EMG
User avatar
Silvio.Falconi
Posts: 7136
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 1 time

Re: ERASE ELEMENT ARRAY

Post by Silvio.Falconi »

resolved
only make me an error when I populate the array if I erase before the array ( at init)
I must add to array one record blank
good it is ok now

Image
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
Willi Quintana
Posts: 1025
Joined: Sun Oct 09, 2005 10:41 pm
Location: Cusco - Perú
Contact:

Re: ERASE ELEMENT ARRAY

Post by Willi Quintana »

Hello..

nPos := 4

ADEL(aDetVen, nPos, .t.) // .t. resize array
Carlos Mora
Posts: 989
Joined: Thu Nov 24, 2005 3:01 pm
Location: Madrid, España

Re: ERASE ELEMENT ARRAY

Post by Carlos Mora »

Hi Willy,

very good point. ADel's 3rd parameter (shrinking the array after delete) is a XHarbour extension, in Harbour this behavoir is available through HB_ADel() function.

regards,
Saludos
Carlos Mora
http://harbouradvisor.blogspot.com/
StackOverflow http://stackoverflow.com/users/549761/carlos-mora
“If you think education is expensive, try ignorance"
Post Reply