|GSAK (Geocaching Swiss Army Knife)|
Array(nArray,nIndex) : string
nArray - must be a number between 1 to 50 that identifies the "in memory" array being used. GSAK currently only supports a maximum of 50 arrays.
nIndex - the index (element number) of the corresponding array
For example, to set 13th element of the "in memory" array number 2 the syntax would be:
To access the same data in the array, is very much like any other function:
You can have up to 2 billion elements in any array but you must first initialize your array and set the maximum number of elements it can contain. Initializing an array sets the number of elements and clears each element (they are all set to "" - empty string)
To initialize an array you just need to use the reserved index number of 0 (zero) and set the required number of elements. For example, if we want the inline memory array number 1 to have 1,000 elements the syntax would be:
Here is an example of saving the cache code and name (in two separate arrays) for your whole database (or current filter)
Arrays also support access to every element, and sorting.
1. Access to the full array
Using the reserved index value of -1 (minus 1) will give you access to the complete array (setting and getting)
For example, to set every element in array number 1 to the string "xxx":
To get the contents of array 1 as a concatenated string of all the elements
2. Sorting arrays
Use the reserved index of -2 (minus 2) to force the contents of the array to be sorted.
You can change the behaviour of the sort by using a combination of flags.
Sequence - A = Ascending, D = Descending (default is A)
Case - I = Ignore case, R = Respect case (default is I)
Type - S = string, N = Numeric (default is S)
These flags can be in any order and are case insensitive. If you don't enter any flags, (or leave out an individual item) then the default values are used for each item.
The "type" flag has been added to help you sort string data (remember, arrays always contain string data) in a true "numerical" way:
For example, take the following macro. If we use the defaults, because we are sorting "strings" we get our data sorted in string order:
To get the array in the correct numerical order we just need to change our sort line to:
If we wanted the data in reverse sequence, we change our sort line to:
Alpha List Category List
Copyright 2004-2014 CWE Computer Services |