Arrays: Difference between revisions

Content added Content deleted
(Add Ecstasy example)
Line 6,055: Line 6,055:


'CREATING A STATIC ARRAY
'CREATING A STATIC ARRAY
float f[100]
float fs[100]


'SETTING INDEX BASE
'SETTING INDEX BASE
Line 6,061: Line 6,061:


'FILLING PART OF AN ARRAY
'FILLING PART OF AN ARRAY
f[20]={2,4,6,8,10,12}
fs[20]={2,4,6,8,10,12}


'MAPPING AN ARRAY TO ANOTHER
'MAPPING AN ARRAY TO ANOTHER
float *g
float *g
@g=@f[20]
@g=@fs[20]
print g[6] 'result 12
print g[6] 'result 12


'DYNAMIC (RESIZEABLE) ARRAYS
'DYNAMIC (RESIZEABLE) ARRAYS
redim float f(100)
redim float fd(100)
f={2,4,6,8} 'assign some values
fd={2,4,6,8} 'assign some values
redim float f(200) 'expand array
redim float fd(200) 'expand array
print f(2) 'original values are preserved by default
print fd(2) 'original values are preserved by default
redim float f(200) clear 'array elements are cleared
redim float fd(200) clear 'array elements are cleared
print f(2) 'value set to 0.0
print fd(2) 'value set to 0.0
redim float f(0) 'release allocated memory '
redim float fd(0) 'release allocated memory '
</syntaxhighlight>
</syntaxhighlight>