RosettaCodeData/Task/Arrays/Yabasic/arrays.basic

29 lines
900 B
Plaintext

dim a(10) // create a numeric array with 11 elements, from 0 to 10
// Indexed at your preference (0 to 9 or 1 to 10)
print arraysize(a(), 1) // this function return the element's higher number of an array
a(7) = 12.3 // access to an element of the array
redim a(20) // alias of 'dim'. Grouth size of array
// Yabasic not allow direct downsize an array, but ...
dim a$(20) // create a textual array with 21 elements
print arraysize(a$(), 1)
void = token("1,2,3,4,5,6,7,8,9,10", a$(), ",") // populate it. Begun with element 1 (not 0).
print arraysize(a$(), 1) // hey! the size is down
print a$(5) // show the content of an element of the array
void = token("", a$()) // "erase" the array content AND redim it to 0 size
print arraysize(a$(), 1)
redim a$(10) // resize the array
print arraysize(a$(), 1)
print a$(5) // show the content of an element of the array. Now is empty