ListKeys

(Engine-Level Function)

Description Returns an array of all keys used within a dictionary. Use this to discover what is in a dictionary.
Returns Array
Usage Script Only.
Function Groups Dictionary,  Variable
Related to: Dictionary | MetaData | DictionaryCopy | DictionaryRemove | GetNextKey
Format: ListKeys( dictionary[, order, return value ]);
Parameters  
Dictionary   
Required. The name of the dictionary.
Order
An optional numeric expression. Defines the search according to the following table of values. Defaults to 0 if missing or invalid

Order

Meaning

0

List in forward alphabetic order.

1

Ordered by when the keys were added to the dictionary with the oldest key first.

2

List in backward alphabetic order

3

Ordered by when the keys were added to the dictionary with the newest key first.

4

Sparse Numeric. Keys must be numeric. Used to return a sparse array in order based on the key values.

Return Value
Controls what is returned according to the following table. Defaults to 1.

Value

Returns

< = 0

Invalid

1

1D array (vector) containing the dictionary keys

2

1D array (vector) containing the dictionary values, ordered by key

3

2D array (table). The first column (left-most) will contain the dictionary keys and the second (right-most) will contain the dictionary values. Ordered by key.

>= 4

Invalid

Example 1:

(given a dictionary named X as shown in the following image)

  R = ListKeys( X );
  R == ["A", "B", "C"];

Example 2:

Given the code:

 If Watch(1); 
  [
    X = Dictionary();
    X["A"] = 42;
    X["B"] = 86;
    X["C"] = 99;
    Buf = ListKeys( X, 1, 3);
  ]

Buff will contain: