getJibba - Tutorial

7.Arrays & Stack

'storing the answers to the 6 times tables
' in an array
For i = 1 To 12
  sixTimesTable[i] = 6 * i

'print out the answers
For i = 1 To Array.GetItemCount(sixTimesTable)

Arrays are variables that can contain more than 1 value. The values in an array are indexed.

A string can be formated as an array like string = "1=val;2=val".

'format weekdays as an array
weekdays = "1=Sunday;2=Monday;3=Tuesday;4=Wednesday;"
weekdays = weekdays + "5=Thursday;6=Friday;7=Saturday"

'print all the days of the week
For i = 1 To Array.GetItemCount(weekdays)

'print the 4th day of the week
TextWindow.Write("the 4th day is: ")

Small basic has several operations for working with arrays.

The Stack Object

'push the 6 times tables onto a stack
For i = 1 To 12
  Stack.PushValue("sixTimesTables", 6 * i)

'pop the values off the stack
While Stack.GetCount("sixTimesTables") > 0

The stack is like a pile of plates. You push values onto it then pop values of it, one at a time. The last value pushed on will be the first value popped off.