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

AVEVA™ E3D Design

Creating a Variable with a Built-in Type

  • Last UpdatedOct 21, 2022
  • 2 minute read

You can create variables of any of the built-in types (REAL, STRING, BOOLEAN or ARRAY), as in the following example, which creates a REAL variable and sets its value to 99:

!MyNumber = 99

Because the variable is set to a real, PML knows that its type is real. Similarly, you can create a STRING variable and set it like this:

!MyString = ‘Hello World’

The PML Variable !MyString and the constant 'Hello World' are both objects of type STRING.

A STRING is a very simple object and the only data it contains is its text value. In this simple expression you are creating a new object, a variable of STRING type, by making a copy of the original object, the STRING constant 'Hello World'.

Other examples:

!!Answer = 42

$* creates !!Answer as a GLOBAL REAL variable.

!Name = 'Fred'

$* creates !Name as a LOCAL STRING variable.

!Grid = TRUE

$* creates !Grid as a LOCAL BOOLEAN variable.

A variable may also be given a type without giving it an initial value, in which case it will have the value UNSET:

!!Answer = REAL()

!Name = STRING()

!Grid = BOOLEAN()

!Lengths = ARRAY()

For more information about unset variables, refer to UNSET Values and UNDEFINED Variables.

!MyDistance = 1metre

This will store a distance of length of 1000mm. Millimeters are the database storage unit for distance. However, if the current distance units are cm the value will be reported as 100cm, and when they are inch units the value will be reported as 39.37inches.

The units and measure of any variable can be queried using the UNITS() and DIMENSION() methods of the REAL object. They will return a UNIT and a MEASURE object. These are built in objects which have their own useful set of methods, and are used in other methods to convert values to different units, and to set and query current working units.

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