structure and sequence. Composite types are those that are composed of one or more values of any general, specific, or composite type. G2 represents system-defined attributes whose values consist of complex data structures with structures and sequences. A
sequence is a list-like value that can contain any item or value, including other sequences and structures. A
structure consists of one or more pairs of names and values. The values of a name/value pair can consist of other structures or sequences. Use structures to represent item attributes and their values. A structure requires an even number of arguments. For more information about working with sequences and structures, see Chapter 12, Attribute Access Facility.
Using the Structure Type
A structure value type consists of a set of subattribute name and value pairs, separated by a colon (:). All name-value subattribute pairs are separated with a comma (,) in this construct:
structure ( [subattribute-name: value [,...] ] )
History-keeping-spec attribute of a variable:
![]() |
the identity of x
for symbol = each symbol that is an attribute name of x do...
change-attribute ( ).
remove-attribute ( ).
structure ( ) creates and returns new structures. Because structures consist of name and value pairs, they require an even number of arguments. The values of attributes of type structure can be any item or value, including other structures and sequences.
When the subattribute of a structure consists of an item, and that item is deleted from the KB, the attribute name remains within the structure, but has a value of
none.
To create a new structure with given attribute values:
structure
(attribute-name: item-or-value [,...] ) -> structure
Creates a new structure containing the given attributes associated with their corresponding values. For example:
structure (measured-item: tank-10, temp: the temp of tank-10)
structure ( ) function, omitting one or more subattributes replaces their current value with none. For example, if the History-keeping-spec attribute of a float-variable float-var-1 is currently:
keep history with maximum number of data points =
100 and maximum age of data points = 2 hours
![]() |
Concluding a new value for the number of data points with an expression such as:
conclude that the history-keeping-spec of float-var-1 =
structure (maximum-number-of-data-points: 50)
![]() |
conclude that
the maximum-number-of-data-points of
the history-keeping-spec of float-var-1 = 50
To create a new structure with given evaluated attribute values:
evaluated-structure
(symbol-expression, item-or-value [,...] ) -> structure
Creates a new structure containing the given attributes associated with their corresponding values. The difference between this function and the structure ( ) function is that this function evaluates the expressions giving the attribute names, while structure ( ) uses the names given explicitly in the form.
To create a new structure with a changed attribute:
change-attribute
(structure, attribute-name, item-or-value) -> structure
Creates a new structure containing all of the same attributes and values in the given structure, but with the given attribute-name containing the given item-or-value.
If the attribute did not exist within the argument structure, the new attribute is added to the end of that structure. If the attribute already exists within the argument structure, the function changes its value, but keeps its position in the original attribute order of the structure.
To create a new structure with a changed evaluated attribute:
change-evaluated-attribute
(structure, symbol-expression, item-or-value) -> structure
Creates a new structure containing all of the same attributes and values in the argument structure, but with the given symbol-expression containing the given item-or-value.
This is the same operation as change-attribute(), except for the attribute name being given by an evaluated expression instead of using the name given explicitly in the form.
To create a new structure with a removed attribute:
remove-attribute
(structure, attribute-name) -> structure
Creates a new structure containing all of the same attributes and values in the argument structure, but with the named attribute removed. If the named attribute was not in the argument, the function returns an exact copy of the argument structure.
To create a new structure with a removed evaluated attribute:
remove-evaluated-attribute
(structure, symbol-expression) -> structure
Creates a new structure containing all of the same attributes and values in the argument structure, but with the named attribute removed. If the named attribute was not in the argument structure, the function returns an exact copy of the argument structure.
To return an attribute value:
Use this expression:
the attribute-name [local-name] of structure
none, G2 signals an error.
To return a named by attribute value:
Use this expression:
the {class-name | type ] that is an attribute of {item | structure} named by symbolic-expression
none, G2 signals an error.
To return attribute values:
Use this expression:
the {class-name | type } that is an attribute of {item | structure }
To return symbols of attributes within a structure:
Use this expression:
the symbol [local-name] that is {a | an} user-defined attribute name of {item | structure}
To return attributes within a structure:
Use this expression:
the symbol [local-name] that is an attribute name of {item | structure}
g2-get-attributes-visible-in-mode system procedure, given administrator as the user-mode argument.
sequence ( [item-or-value [,...] ] )
Item-configuration attribute value.
![]() |
Sequences are functionally similar to lists. As such, you can access their elements by:
insert-at-beginning ( ), insert-at-end ( ).
insert-after ( ) function.
insert-before-element ( ), insert-after-element ( ).
none, but does not decrease the number of elements.
To return a new sequence containing the given elements:
sequence -> sequence
Returns a new sequence containing the given elements. Sequences may contain from zero to 1,046,526 elements.
get-debug (P:class procedure)
x: sequence;
begin
x = sequence (the tracing-and-breakpoints-of P);
end
To return a new sequence one element shorter than the given sequence:
remove
(sequence, integer) -> sequence
Returns a new sequence one element shorter than the given sequence, where the element at the given index has been removed. The first element is at index 0. If the given index does not name an element of the sequence, an error is signalled.
To return a new sequence whose first element is the given item-or-value:
insert-at-beginning
(sequence, item-or-value) -> sequence
Returns a new sequence whose first element is the given item-or-value, and whose remaining elements are all elements in the given sequence.
To return a new sequence with specific elements inserted:
insert-at-end -> sequence
Returns a new sequence whose elements are those in the given sequence, but which also contains an additional last element which is the given item-or-value. This operation is generally faster than insert-at-beginning for incrementally collecting large sequences.
Sequences are stored as arrays, potentially with some empty elements at the end of the array as the sizes of data structures are rounded up to allocated sizes. In many cases, elements added to the end of sequences may be filled into these empty locations without having to shift the previous elements in the sequence.
To return a new sequence with inserted arguments:
insert-after
(sequence, item-or-value, item-or-value) -> sequence
Returns a new sequence with the same elements as the argument sequence, but with the second argument inserted after the first occurrence of the third argument within the sequence.
To return a new sequence with inserted elements before a given index:
insert-before-element -> sequence
Returns a new sequence with the same elements as the argument sequence, but with the third argument inserted into the sequence at the index given as the second argument.
The allowable range for the index argument of a sequence is:
To return a new sequence with inserted elements after a given index:
insert-after-element -> sequence
Returns a new sequence with the same elements as the argument sequence, but with the third argument inserted into the sequence immediately after the index given as the second argument.
The allowable range for the index argument of a sequence is:
To change a single element of a sequence:
change-element -> sequence
Returns a new sequence with the same elements as the argument sequence, but with the value at the index location changed to the given item-or-value. The first element is at index 0, and it is an error if the index is larger than the current size of the given sequence.
To concatenate two or more sequences:
concatenate -> sequence
Returns a new sequence containing the combined elements of the argument sequences, with all elements of those sequences concatenated in order to form the new sequence.
To get a portion of a sequence:
portion
(sequence, integer, integer) -> sequence
Returns a new sequence containing a portion of the elements of the argument sequence. The first integer argument is the index at which to start copying, and the second integer argument is the number of elements to return in the new sequence.
To obtain a particular element in a sequence:
{g2-list | g2-array | sequence | text} [integer]
To iterate over elements in a sequence:
the {class-name | type} [local-name] in {g2-list | g2-array | sequence}
-> [item | integer | float | symbol | text | truth-value | structure | sequence]
Returns each element of the given type found within the sequence.
To return an element of a particular type from a sequence:
the {first | second | next to last | last { class-name | type} in {g2-list | sequence }
Returns the element of the given type at the described position within the g2-list or sequence.
To determine whether an item-or-value is a member of a sequence:
{item-or-value} is [not] a member of {g2-list | sequence}
Returns whether or not the given item-or-value is a member of the sequence.
To determine the number of elements in a sequence:
the number of elements in {g2-list | sequence}
Returns the number of elements in the given sequence.