Jump to content
Sign in to follow this  

address element of an Array *IN* another array?

Recommended Posts



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!

Share this post

Link to post
Share on other sites

Hi rudi,


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))

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

Hope this helps, ;)


Share this post

Link to post
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
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.