|
'-------------
'STATIC ARRAYS
'=============
dim as long a(10)={2,4,6,8,10,12}
a(10)=a(1)+a(4)
print a(10)
'--------------
'DYNAMIC ARRAYS
'==============
dim as long a at getmemory(10*sizeof(long)) : a={2,4,6,8,10,12}
...
freememory @a
dim as long a(10)={2,4,6,8,10,12}
'--------
'OVERLAYS
'========
dim as string s = "ABCDEFGHIJ"
dim as byte b at strptr(s)
'print b[3] ": " chr(b[3])
'-----------------------
'MULTIDIMENSIONAL ARRAYS
'=======================
macro a(x,y) av(y*1024+x)
dim int av[1024*1024]
a(100,200)=42
'print a(100,200) ;42
'----------
'INDEX BASE
'==========
'
dim int a[100]={10,20,30,40}
indexbase 1 'default: first element is indexed as 1
'print a[2] '20
indexbase 0
'print a[2] '30
'-------------
'PSEUDO ARRAYS
'=============
dim av[100]
function a(int i,v) 'setter
i*=2
av[i]=v
end function
function a(int i) as int 'getter
i*=2
return av[i]
end function
a(7)=42 'this is interpreted as a(7,42)
'print a(7)
|