Hi Charles,
using your example code, I tried to create a 3-dimensional array in three ways. Only using the function iarr will show the correct results. Am I missing something with the macro iarr? I am also not sure if I forgot something with macro arr3d?
Roland
uses console
#autodim off
indexbase 0
int arr[3*2*4]=
{11, 12, 13, 14,
15, 16, 17, 18,
21, 22, 23, 24,
25, 26, 27, 28,
31, 32, 33, 34,
35, 36, 37, 38}
function iarr(int x,y,z) {return x*2*4 + y*4 + z}
'macro iarr(x,y,z) (x*2*4 + y*4 + z)
macro arr3d int* (r,x,y,z)
'r return value
@r=@arr(x*2*4 + y*4 + z)
end macro
printl "- 3D Array Elements - " + cr +cr
int i, j, k
int idx
for i=0 to <3
for j=0 to <2
for k=0 to <4
idx = iarr(i,j,k)
print arr[idx] : print tab
' print arr3d(i,j,k) : print tab
next
printl
next
printl
next
printl "-----------------------------" : printl : printl
for i=0 to <3
for j=0 to <2
for k=0 to <4
idx = i*2*4 +j*4 +k
print idx tab
next
printl
next
printl
next
printl "Enter ..." : waitkey