#111898 - 2004-01-16 08:04 AM
Nesting elements
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
This works... but does -
Quote:
1 A
1 B
1 C
1 D
etc.
Code:
cls
break on
$1=Split('1 2 3 4 5 6 7 8 9')
FOR EACH $e1 IN $1
$a=Split('A B C D E F G H I')
FOR EACH $e2 IN $a
?$e1+' '+$e2
NEXT
NEXT
GET $
What I am trying to do is -
Quote:
1 A
2 B
3 C
4 D
I am probably missing something really simple.
Code:
cls
break on
$1=Split('1 2 3 4 5 6 7 8 9')
$A=Split('A B C D E F G H I')
FOR EACH $e1 IN $1+$A
?$E1
NEXT
get $
Thanks,
Kent
|
|
Top
|
|
|
|
#111900 - 2004-01-16 09:52 AM
Re: Nesting elements
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Without context it's a bit difficult to see what you are trying to achieve.
It looks like you want some sort of associative array.
Here's one way of doing it, but this will only work if the entries in the first array are unique:
Cls Break ON $aiNumbers=Split('1 2 3 4 5 6 7 8 9') $asLetters=Split('A B C D E F G H I') For Each $sKey In $aiNumbers $sKey+" "+$asLetters[AScan($aiNumbers,$sKey)] ? Next Get $
|
|
|
Top
|
|
|
|
#111901 - 2004-01-16 09:56 AM
Re: Nesting elements
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
If you just want to iterate the two arrays in parallel, do as Jooel suggested:
Cls Break ON $aiNumbers=Split('1 2 3 4 5 6 7 8 9') $asLetters=Split('A B C D E F G H I') For $iKey=0 To UBound($aiNumbers) $aiNumbers[$iKey]+' '+$asLetters[$iKey] ? Next Get $
|
|
|
Top
|
|
|
|
#111903 - 2004-01-16 10:08 AM
Re: Nesting elements
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Quote:
so, you had to first go the fancy way around?
Of course! The simple answer was not interesting enough to warrant a post 
I couldn't decide (from the example) why a simple problem would cause difficulties for a long-termer like Kent, so I assumed that the requirement must be more complex than stated in the first post.
|
|
Top
|
|
|
|
#111906 - 2004-01-17 05:09 PM
Re: Nesting elements
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
Perfect! That works a treat!
Kent
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
1 registered
(Allen)
and 1607 anonymous users online.
|
|
|