GetPreviousKey |
Arrays | |
Aptilis 1 |
GetPreviousKey(ArrayName[])
GetPreviousKey gets the previous key of an array.
Each array has a hidden index which you can set
with SetArrayIndex
to access all its values or keys 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:
Next array key.
Example 1:
a["one"] = "un" $ a["two"] = "deux" $ a["three"] = "trois" $ SetArrayIndex(a[], "begin") n = getarraysize(a[]) for i = 1 to n key = GetPreviousKey(a[]) $ print("The French for '", key$, "' is '", a[key$]$, "'\n") end forResult:
The French for 'three' is 'trois' The French for 'two' is 'deux' The French for 'one' is 'un' |
See also
SetArrayIndex,
GetNextkey,
GetArraysize,
ClearArray.