OScript API/Built-in Package Index |
The built-in functions in the Assoc package allow you to manipulate the Assoc (Associative) data type. An Assoc is a map for associating arbitrary key/value pairs. An Assoc differs from a Record in that the keys are less expensive to add and remove, the keys can be data types other than Strings, and the keys are sorted by key comparison rather than by some fixed order.
Each Assoc has an "undefined value" that is returned when a nonexistent key is referenced. This "undefined value" is usually Undefined by default, but Assoc.NotSetValue() or any other value may be used.
An Assoc is formally created with Assoc.CreateAssoc(), however OScript has a convenience feature in that this is automatically invoked when an Assoc is declared so that it can be used right away. This does not happen with a Record since, while Assoc is meant to be a tool for relating data in an OScript program, Record is meant to be a tool for accessing database table data.
The constant type identifier for the Assoc data type.
Returns a duplicate Assoc.
Returns a new Assoc.
Returns a new Assoc.
Removes a key/value pair from an Assoc.
Converts a Record to an Assoc.
Returns an assoc containing key/value pairs from the argument list key.
Returns true if the Assoc contains key.
Returns a List of all the values in an Assoc.
Returns a List of all the keys in an Assoc
Merges assoc2 into assoc1.
Returns a unique data type constant which can be used as the "undefined value".
Converts an Assoc into a Record.
Returns and optionally sets the "undefined value" of an Assoc.
The type number for the Assoc data type.
Creates and returns a shallow copy of the specified source Assoc. This is necessary since Assocs are passed by reference, meaning that simple assignment does not copy an Assoc as it does with an Integer. The copying process follows the same conventions used in function parameter passing. Thus the contents of the copy will contain copies of those values in the source which are passed by value, and and references to those values in the source which are passed by reference. The following example illustrates this:
The Assoc to copy.
The new Assoc copy.
Returns a new, empty Assoc whose "undefined value" will be Undefined or value if value is specified. The "undefined value" is the value returned by an Assoc when referenced by a key it does not contain.
The "undefined value" of the returned Assoc, which will be Undefined if this argument is not specified.
A new, empty Assoc.
Returns a new Assoc with values as specified in the input arg list.
First key
First value
Second key
Second value
A new Assoc.
Removes the specified key from the Assoc if that Assoc contains the key.
The Assoc to remove a key/value pair from.
The key for the key/value pair to remove.
The value removed, or the "undefined value" if the key was not found.
Creates and returns a new Assoc containing the field names and corresponding columns of the specified Record as its String keys and associated values. As with Assoc.Copy(), the new Assoc returned will be a shallow copy of the Record.
The Record from which an Assoc will be created.
A new Assoc, copied from the Record.
Returns true if this assoc contains any self-referencing cycles.
The Assoc to be checked.
True if the Assoc contains any self-referencing cycles.
Returns true if the specified Assoc contains the specified key.
The Assoc whose key set is tested.
The key to test.
True if the Assoc contains the key.
Returns a List of the keyed values in a.
The Assoc whose values are returned in a List.
A List of the keyed values in the Assoc.
Returns a List of the keys in a.
The Assoc whose keys are returned in a List.
A List of keys in the Assoc.
The two Assocs are merged by copying the contents of assoc2 into assoc1. The copy process is the same as used for Assoc.Copy(). If a key is common to both Assocs, then the associated value in assoc1 will be replaced by that in assoc2, as shown by the following example:
Destination Assoc for merge.
Assoc whose contents are copied into assoc1.
A reference to the first assoc passed in.
Returns a unique data type constant useful as the "undefined value" for an Assoc when Undefined or other values will not work since they might be keys within the Assoc. Use with Assoc.CreateAssoc() or Assoc.UndefinedValue().
A unique data type constant useful as the "undefined value" for an Assoc.
Creates a new Record and returns it after copying the values of the given Assoc into it, translating String keys and values into field names and column entries. The Assoc should only contain String keys. As with Assoc.Copy(), the new Assoc returned will be a shallow copy of the Record.
The Assoc to convert into a new Record.
A new Record copied from the Assoc.
Returns the "undefined value" for the specified Assoc. If value is specified than the "undefined value" for the Assoc will be changed to value (meaning value will be returned).
The Assoc whose "undefined value" is queried and optionally set.
If specified, then the "undefined value" of _a _will be set to this.
The "undefined value" for the Assoc.
Copyright © 2022 OpenText Corporation. All rights reserved. |