SIMPOL Documentation

array

Description

Array objects are actually objects in their own right, they are not arrays of some single other type. The array implementation in SIMPOL is extremely flexible. Typical array implementation can be considered to be a subset of the SIMPOL array type. SIMPOL array objects do not need to be sized in advance, nor are they of one particular type. They can also house elements at every level of the array (in the case of a multidimensional array). The subscript of an array element can also be a string. An array can hold values and references to objects. Assigning a value type to an array element assigns the value to the element. It does not also contain a reference to a value type. To assign a reference to an object to an array element it is necessary to use the reference assignment operator (@= or =@). To clear an element it is necessary to assign a reference to .nul.

Type Tags

None

Object Value

The value of an object of type array is undefined and it is an error to attempt to get or to set it.

array.new()

Description

Creates a new array object.

Prototype

array.new ()

Parameters

None

Properties

PropertyTypeDescription
typetype Specifies the array type object.

Methods

count()

Description

Returns the count of items that are hierarchically below the item referenced by the subscript including the subscript itself. For example: a.count(1,2) if there is an item located at a[1,2] then this will count as 1, and all items subscripted below a[1,2], such as a[1,2,1] or a[1,2,1,3] will also count assuming that those points actually contain a value or a reference. The count() method is not particularly useful unless a certain degree of discipline and design are used with this type. If the array is used in a more typical way, then this method will work as expected, assuming that the subscripts begin with the value 1 and are sequential from there.

Prototype

arrayvar.count ( integer|string count )

Parameters
ParameterDefault valueType nameDescription
countNoneinteger|string If no argument is passed then all of the elements will be counted. Otherwise it is as described above. There is no way to detect the subscripts of elements if they are out of sequence or based on strings. If the value passed is equal either to .nul or .inf then the return value will be .nul.

array[]

Get

Subscripts

An integer or string value giving the index position of an item in the list. This can be a single integer, a string, the empty value ([]), or a hierarchical position, such as [1,2]. Even a combination of index values is permitted, such as: [1, "blue"].

Description

Retrieves the value or object at the specified index position.

Set

Subscripts

An integer or string value giving the index position of an item in the list. This can be a single integer, a string, the empty value ([]), or a hierarchical position, such as [1,2]. Even a combination of index values is permitted, such as: [1, "blue"].

Description

Assigns a value to the specified index position in the array.

Set Reference

Subscripts

An integer or string value giving the index position of an item in the list. This can be a single integer, a string, the empty value ([]), or a hierarchical position, such as [1,2]. Even a combination of index values is permitted, such as: [1, "blue"].

Description

Assigns a reference to an object to the specified index position in the array.