Arrays: Difference between revisions

Content added Content deleted
Line 5,526: Line 5,526:
<lang oxygenbasic>
<lang oxygenbasic>


'CREATING AN ARRAY
'CREATING A STATIC ARRAY

float f[100]
float f[100]


'SETTING INDEX BASE
'SETTING INDEX BASE

indexbase 1 'default
indexbase 1 'default


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

f[20]<=1,2,3,4,5,1.25


'MAPPING AN ARRAY TO ANOTHER
'MAPPING AN ARRAY TO ANOTHER

float *g
float *g
@g=@f[20]
@g=@f[20]
print g[6] 'result 1.25
print g[6] 'result 12


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