ERASE ELEMENT ARRAY

ERASE ELEMENT ARRAY

Postby Silvio.Falconi » Wed Oct 07, 2015 7:13 am

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

Re: ERASE ELEMENT ARRAY

Postby Carlos Mora » Wed Oct 07, 2015 7:22 am

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

Re: ERASE ELEMENT ARRAY

Postby Silvio.Falconi » Wed Oct 07, 2015 7:29 am

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
Silvio.Falconi
 
Posts: 7052
Joined: Thu Oct 18, 2012 7:17 pm

Re: ERASE ELEMENT ARRAY

Postby Enrico Maria Giordano » Wed Oct 07, 2015 8:14 am

Silvio,

build a complete sample showing the problem, please.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: ERASE ELEMENT ARRAY

Postby Silvio.Falconi » Wed Oct 07, 2015 8:30 am

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 view


#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
Silvio.Falconi
 
Posts: 7052
Joined: Thu Oct 18, 2012 7:17 pm

Re: ERASE ELEMENT ARRAY

Postby Enrico Maria Giordano » Wed Oct 07, 2015 8:50 am

Silvio,

Code: Select all  Expand view
#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
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: ERASE ELEMENT ARRAY

Postby Silvio.Falconi » Wed Oct 07, 2015 11:00 am

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
Silvio.Falconi
 
Posts: 7052
Joined: Thu Oct 18, 2012 7:17 pm

Re: ERASE ELEMENT ARRAY

Postby Enrico Maria Giordano » Wed Oct 07, 2015 11:09 am

Silvio,

Code: Select all  Expand view
asize( aDataDisposizioni, 0 )


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: ERASE ELEMENT ARRAY

Postby Silvio.Falconi » Wed Oct 07, 2015 11:11 am

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
Silvio.Falconi
 
Posts: 7052
Joined: Thu Oct 18, 2012 7:17 pm

Re: ERASE ELEMENT ARRAY

Postby Willi Quintana » Wed Oct 07, 2015 11:00 pm

Hello..

nPos := 4

ADEL(aDetVen, nPos, .t.) // .t. resize array
User avatar
Willi Quintana
 
Posts: 1019
Joined: Sun Oct 09, 2005 10:41 pm
Location: Cusco - Perú

Re: ERASE ELEMENT ARRAY

Postby Carlos Mora » Thu Oct 08, 2015 7:50 am

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 54 guests