GetPrevious |
Arrays | |
Aptilis 1 |
GetPrevious(ArrayName[])
GetPrevious gets the previous value of an
array. Each array has a hidden index which you
can set with SetArrayIndex
to access all its values one by one.
Once you've gotten the last element available,
the hidden index goes back to the end of the array.
This is particulary useful with arrays that use string key
indexing (rather than numbers), when you do not know
the different keys.
Return value:
Previous array element.
Example 1:
a[0] = "Apple" $ a[1] = "Banana" $ a[2] = "Cherry" $ SetArrayIndex(a[], "end") n = getarraysize(a[]) for i = 1 to n print(getprevious(a[])$, "\n") end forResult:
Cherry Banana Apple |
Example 2, a Franco-English fruit dictionary:
a["Pomme"] = "Apple" $ a["Banane"] = "Banana" $ a["Cerise"] = "Cherry" $ SetArrayIndex(a[], "end") n = getarraysize(a) for i=0 to n - 1 print(getPrevious(a[])$, "\n") end forResult:
Cherry Banana Apple |
See also
SetArrayIndex,
GetNext,
GetArraysize,
ClearArray.