Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ Engineering

Creating Array Variables

  • Last UpdatedOct 24, 2022
  • 2 minute read

An ARRAY variable can contain many values, each of which is called an array element. An ARRAY is created automatically by creating one of its array elements.

For example, to create element one of a new array named NewArray:

!NewArray[1] = !NewValue

This will create an array variable named !NewArray if it does not already exist, and will set element 1 of that array to the value of !NewValue. If !NewArray already exists as a simple variable, you will get an error message and the command will be ignored.

Note:
Array elements are referred to by means of a subscript expression in [ ] square brackets and that there must be no space between the end of the array name and the subscript.

Array elements are accessed in the same way when using the value in an expression:

!Average = ( !Sample[1] + !Sample[2] + !Sample[3] ) / 3

It is also possible to create an empty array which has no elements:

!X = ARRAY()

The array subscript may be any expression which evaluates to a number. One of the simplest expressions is the value of a variable:

!MyArray[!Next] = 15

The individual elements of an array variable can be set independently and in any order. Thus you can set !X[1] and !X[10] without setting any of the intervening elements !X[2] to !X[9]. In other words PML arrays are allowed to be 'sparse' and to have gaps between the subscript numbers which have values set.

Note:
Negative subscripts are no longer permitted.

An array subscript of zero is allowed but you are advised against using it as many of the array facilities ignore array element zero.

An array subscript may be an expression of any complexity provided it evaluates to a positive REAL result and may even include a call to a PML function.

For example:

!Value = !MyArray[!A + (!B * !!MyFunction() ) + !C ]

PML arrays may be heterogeneous. That is to say, the elements of a PML array do not have to be all of the same type. Array elements may even be User-defined objects.

Non-existent array elements - after the last set element of the array and the non-existent elements in the gaps of a sparse array - are all UNDEFINED: the function Undefined() will return TRUE, and the function Defined() will return FALSE for all these subscripts.

Related Links
TitleResults for “How to create a CRG?”Also Available in