Sunday, June 01, 2008

Compatibility Step 6 -- Multi dimensional Arrays

This one was not straight forward because javascript doesn't have a simple syntactic construct to create a multi dimensional arrays. As of today though, QuiteBASIC has just that. For example:

10 DIM A(5,6,4)

declares a 3D array.

The array can then be used in LET commands and in expressions just like you expect it to. For example:

20 LET A(1,2,3) = 64
30 PRINT SQR(A(1,2,3))

will print 8.

This only works with the DIM command. The ARRAY command just declares a 1D array of dynamic size. And this only works with the parenthesis syntax for array indices. So A[1,2,3] is a syntax error.

I also added the TAB(x) function which is typically used in PRINT commands to format the output. For example:

40 PRINT TAB(5); "Hello!"

will print five spaces followed by "Hello!".

0 Comments:

Post a Comment

<< Home