AEVAL multidimentional array
-
- Posts: 1173
- Joined: Mon Oct 17, 2005 5:41 am
- Location: Belgium
- Contact:
AEVAL multidimentional array
Hi,
Is is possible to aeval a multidimentional array, or do I have to make a combination of a loop and aeval.
I want to execute a function on all elements of a multidimentional array.
Thank you
Is is possible to aeval a multidimentional array, or do I have to make a combination of a loop and aeval.
I want to execute a function on all elements of a multidimentional array.
Thank you
Regards,
Marc
FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Marc
FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
- Antonio Linares
- Site Admin
- Posts: 42854
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 185 times
- Been thanked: 124 times
- Contact:
-
- Posts: 1173
- Joined: Mon Oct 17, 2005 5:41 am
- Location: Belgium
- Contact:
Re: AEVAL multidimentional array
Antonio,
Here is an example of the array. The normal one is much bigger
I want to perform a function on each element.
For example remove all " at the beginning and end of the element.
Here is an example of the array. The normal one is much bigger
Code: Select all | Expand
"E1345";"DI";"DIGACQA";"DI";"I_E1345"
"F1305";"GO";"DEVCTLA";"DI";"I_F1305GO
"F1305";"GT";"DEVCTLA";"DI";"I_F1305GT"
For example remove all " at the beginning and end of the element.
Regards,
Marc
FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Marc
FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
- Antonio Linares
- Site Admin
- Posts: 42854
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 185 times
- Been thanked: 124 times
- Contact:
Re: AEVAL multidimentional array
AEval( aLines, { | cLine, n | aLines[ n ] := SubStr( cLine, 2 ), aLines[ n ] := SubStr( aLines[ n ], 2, Len( aLines[ n ] ) - 1 ) } )
You can also manage each line as an array:
AEval( aLines, { | cLine, n | aLines[ n ] := hb_ATokens( cLine, ";" ) } )
You can also manage each line as an array:
AEval( aLines, { | cLine, n | aLines[ n ] := hb_ATokens( cLine, ";" ) } )
-
- Posts: 1173
- Joined: Mon Oct 17, 2005 5:41 am
- Location: Belgium
- Contact:
Re: AEVAL multidimentional array
Antonio,
Sorry for the confusion,but the ';' between each element, is not a real ';' , but a separation between element
So the array is in fact
Sorry for the confusion,but the ';' between each element, is not a real ';' , but a separation between element
So the array is in fact
Code: Select all | Expand
{ { ' "E1345" ' , ' "DI" ' , ' "DIGACQA" ' , ' "DI" ' ,' "I_E1345" ' } , {' "F1305" ' , ' "GO" ' ,' "DEVCTLA" ' ,' "DI" ' ,' "I_F1305GO" '} , {' "F1305" ' ,' "GT" ' ,' "DEVCTLA" ' ,' "DI" ' ,' "I_F1305GT" '} }
Regards,
Marc
FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Marc
FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
- Antonio Linares
- Site Admin
- Posts: 42854
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 185 times
- Been thanked: 124 times
- Contact:
Re: AEVAL multidimentional array
Then it is simpler:
AEval( aLines, { | aLine, n | AEval( aLine, { | cElement, m | ... } ) } )
AEval( aLines, { | aLine, n | AEval( aLine, { | cElement, m | ... } ) } )
-
- Posts: 1173
- Joined: Mon Oct 17, 2005 5:41 am
- Location: Belgium
- Contact:
Re: AEVAL multidimentional array
Thank you Antonio.
Regards,
Marc
FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Marc
FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
-
- Posts: 1173
- Joined: Mon Oct 17, 2005 5:41 am
- Location: Belgium
- Contact:
Re: AEVAL multidimentional array
Antonio,
I still have a little problem.
I tested it with
It execute the mcsvremove() function, but the array is not updated.
If I add a message in mcsvremove(), the funcion removed the "
I still have a little problem.
I tested it with
Code: Select all | Expand
AEval( aLines, { | aLine, n | AEval( aLine, { | cElement, m | cElement := mcsvremove(cElement) } ) } )
func mcsvremove(vveld)
vveld = alltrim(vveld)
msginfo(vveld) //field with "
if substr(vveld,1,1) = '"'
vveld = substr(vveld,2,len(vveld)-2)
endif
msginfo(vveld) //field without "
return vveld
If I add a message in mcsvremove(), the funcion removed the "
Regards,
Marc
FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Marc
FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
- Antonio Linares
- Site Admin
- Posts: 42854
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 185 times
- Been thanked: 124 times
- Contact:
Re: AEVAL multidimentional array
Marc,
Do it this way:
Do it this way:
Code: Select all | Expand
AEval( aLines, { | aLine, n | AEval( aLine, { | cElement, m | aLines[ n ][ m ] := mcsvremove(cElement) } ) } )
func mcsvremove(vveld)
vveld = alltrim(vveld)
msginfo(vveld) //field with "
if substr(vveld,1,1) = '"'
vveld = substr(vveld,2,len(vveld)-2)
endif
msginfo(vveld) //field without "
return vveld
-
- Posts: 1173
- Joined: Mon Oct 17, 2005 5:41 am
- Location: Belgium
- Contact:
Re: AEVAL multidimentional array
Antonio,
Then I get this compile-error.
Then I get this compile-error.
Code: Select all | Expand
Error E0005 Outer codeblock variable is out of reach: 'N'
Regards,
Marc
FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Marc
FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
-
- Posts: 79
- Joined: Tue Feb 09, 2021 4:20 pm
- Been thanked: 2 times
Re: AEVAL multidimentional array
Try This
Code: Select all | Expand
FOR EACH aList2 IN aList
FOR EACH xItem IN aList2
callfunction( @xItem )
NEXT
NEXT
José M. C. Quintas Brazil
gtwvg, fivewin 25.01, hwgui, mingw 15.1 (32 bits)
gtwvg, fivewin 25.01, hwgui, mingw 15.1 (32 bits)