This task is about arrays.

For hashes or associative arrays, please see Creating an Associative Array.

For a definition and in-depth discussion of what an array is, see Array.



Task

Show basic array syntax in your language.

Basically, create an array, assign a value to it, and retrieve an element   (if available, show both fixed-length arrays and
dynamic arrays, pushing a value into it).

Please discuss at Village Pump:   Arrays.

Please merge code in from these obsolete tasks:

   Creating an Array
   Assigning Values to an Array
   Retrieving an Element of an Array


Related tasks

   Collections
   Creating an Associative Array
   Two-dimensional array (runtime)


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