FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour ERASE ELEMENT ARRAY
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
ERASE ELEMENT ARRAY
Posted: Wed Oct 07, 2015 07: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 March-April 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
Posts: 989
Joined: Thu Nov 24, 2005 03:01 PM
Re: ERASE ELEMENT ARRAY
Posted: Wed Oct 07, 2015 07: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"
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: ERASE ELEMENT ARRAY
Posted: Wed Oct 07, 2015 07: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

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 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
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: ERASE ELEMENT ARRAY
Posted: Wed Oct 07, 2015 08:14 AM

Silvio,

build a complete sample showing the problem, please.

EMG

Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: ERASE ELEMENT ARRAY
Posted: Wed Oct 07, 2015 08: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 (fw): Select all Collapse
#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 March-April 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
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: ERASE ELEMENT ARRAY
Posted: Wed Oct 07, 2015 08:50 AM
Silvio,

Code (fw): Select all Collapse
#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
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: ERASE ELEMENT ARRAY
Posted: 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 March-April 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
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: ERASE ELEMENT ARRAY
Posted: Wed Oct 07, 2015 11:09 AM
Silvio,

Code (fw): Select all Collapse
asize( aDataDisposizioni, 0 )


EMG
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: ERASE ELEMENT ARRAY
Posted: 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

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 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
Posts: 1054
Joined: Sun Oct 09, 2005 10:41 PM
Re: ERASE ELEMENT ARRAY
Posted: Wed Oct 07, 2015 11:00 PM

Hello..

nPos := 4

ADEL(aDetVen, nPos, .t.) // .t. resize array

Posts: 989
Joined: Thu Nov 24, 2005 03:01 PM
Re: ERASE ELEMENT ARRAY
Posted: Thu Oct 08, 2015 07: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"

Continue the discussion