Liberty BASIC Help Online

Arrays with More than Two Dimensions
 
Although Liberty BASIC only allows arrays with one or two dimensions, arrays with three or more dimensions can be easily simulated.  To simulate an array of 10 by 10 by 10, it is possible to stack the third dimension on top of the second:
 
'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


Copyright (C) 2003 Shoptalk Systems
Liberty BASIC - http://www.libertybasic.com/