Jump to content

address element of an Array *IN* another array?


Recommended Posts

Hi.

for "arrays in an 'array of arrays' " I would like to directly address single elements of the "inner arrays", howto?

Dim $a1[4]=[3,"a","b","c"]
Dim $a2[4]=[3,"x","y","z"]

dim $aAll[3]=[2,$a1,$a2]

$foo=$aAll[2] ; copy the "inner array" to some temporary array is the only way I can currently see, how to solve this. Not efficient!
ConsoleWrite($foo[2] & @CRLF)

; some thing like:
; ConsoleWrite(($All[2])[2] & @CRLF)

Regards, Rudi.

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
Share on other sites

Hi rudi,

howto?

Here's one way :)

Dim $a1[4] = [3, "a", "b", "c"]
Dim $a2[4] = [3, "x", "y", "z"]

Dim $aAll[3] = [2, $a1, $a2]

For $i = 1 To $aAll[0]
    For $j = 1 To _ArrayRead($aAll[$i], 0)
        MsgBox(0, "$aAll[" & $i & "]", "$aNestedArray[" & $j & "] = " & _ArrayRead($aAll[$i], $j))
    Next
Next

Func _ArrayRead(ByRef $avArray, $iIndex)
    Return $avArray[$iIndex]
EndFunc   ;==>_ArrayRead

Hope this helps, ;)

-smartee

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...