Declaration / Creation

Updated May 2022

dimx $aryname, ordmap (varstr; varstr)

dimx $aryname, ordmap (varstr; varx)

dimx $aryname, ordmapm (varstr; varstr)

dimx $aryname, ordmapm (varstr; varx)

$aryname is the name of the ordered map. It follows the normal rules of ASB variable names except that it must begin with a $. Also note that although $aryname is an array, and you will need to use parentheses to reference it later, e.g. $aryname("some key") = "some value", the parentheses are omitted from the declaration.

The varstr; varstr and varstr; varx suffixes following the data types ordmap or ordmapm refer to the types of the keys and the types of the values. The only supported key type is varstr, meaning a variable-length, null-terminated string. The value type can also be varstr or it can be varx, meaning a variable-length raw or unformatted blob, such as can be stored in a type X or a structure variable.

The ordmap variant does not allow multiple key-value pairs with the same key. (The assignment $m("foo") = "bar" will replace any prior key-value pair with the key "foo".) The ordmapm variant allows any number of pairs to have the same key.

The ordered map grows dynamically as items are added or deleted, so there is no need to declare any sizes.

See Also

•   Element assignment and removal