## 3 dimmensinional arrays

Expand Messages
• from the docs: create an array big enough to hold 10x10x10 elements dim myArray\$(10, 100) set a value in the array in 3 dimensions call setMyArray\$ 5, 6, 7,
Message 1 of 2 , Jun 2, 2005
• 0 Attachment
from the docs:

'create an array big enough to hold 10x10x10 elements
dim myArray\$(10, 100)

'set a value in the array in 3 dimensions
call setMyArray\$ 5, 6, 7, "Here I am!"

'now fetch and print out the value
print getMyArray\$(5, 6, 7)

end

sub setMyArray\$ x, y, z, value\$
myArray\$(x, y + z * 10) = value\$
end sub

function getMyArray\$(x, y, z)
getMyArray\$ = myArray\$(x, y + z * 10)
end function

it sounds like a nice idea but if I want to place a value at 10,10,10
like:

call setMyArray\$ 10, 10, 10, "Here I am!"

the associated call:

print getMyArray\$(10, 10, 10)

gets an error as expected. the fix is to dim the array larger:

dim myArray\$(10, 120)

this could probably be noted in the docs.

--
http://home.cogeco.ca/~tsummerfelt1
telnet://ventedspleen.dyndns.org
• Tony, since the second value is calculated like y + z * 10 the array must be dimmed to 10 + 10 * 10 elements, which is 110. There will be an update to the
Message 2 of 2 , Jun 2, 2005
• 0 Attachment
Tony,
since the second value is calculated like y + z * 10 the array must be dimmed
to 10 + 10 * 10 elements, which is 110.
There will be an update to the helpfile, I will post this at the helpfile bugs
board at conforums.

---
Stefan Pendl

> -----Ursprüngliche Nachricht-----
> Von: libertybasic@yahoogroups.com
>
> from the docs:
>
> 'create an array big enough to hold 10x10x10 elements
> dim myArray\$(10, 100)
>
> 'set a value in the array in 3 dimensions
> call setMyArray\$ 5, 6, 7, "Here I am!"
>
> 'now fetch and print out the value
> print getMyArray\$(5, 6, 7)
>
> end
>
> sub setMyArray\$ x, y, z, value\$
> myArray\$(x, y + z * 10) = value\$
> end sub
>
> function getMyArray\$(x, y, z)
> getMyArray\$ = myArray\$(x, y + z * 10)
> end function
>
> it sounds like a nice idea but if I want to place a value at 10,10,10
> like:
>
> call setMyArray\$ 10, 10, 10, "Here I am!"
>
> the associated call:
>
> print getMyArray\$(10, 10, 10)
>
> gets an error as expected. the fix is to dim the array larger:
>
> dim myArray\$(10, 120)
>
> this could probably be noted in the docs.
Your message has been successfully submitted and would be delivered to recipients shortly.