Variables

Variables can be of any of the seven operand types: integer, real, string, point, feature pointer, array, and function. Variables come into existence and receive their value and type via the ASSIGN statement. The variable ID can be any alphanumeric string that does not begin with a numeric character. Underscores can also be used in the variable id provided that the underscore is not the first character.

Variable values are saved between execution runs. This means if routine execution stops and re-starts, the values the variables have when execution stops will be the same values when execution starts again.

If the Edit window is active, PC-DMIS indicates the current value of the variable whenever the cursor is placed in the field. During execution, variable values change based on execution flow. Position the mouse pointer over the desired variable to find out its current value.

ASSIGN/V1=2.2+2
Variable V1 is a real number with the value of 4.2

ASSIGN/VAR1=CIRCLE1.X
Variable VAR1 is a real number with a value equal to the measured value of CIRCLE1.X at the time of assignment.

ASSIGN/MYVAR=LINE1.XYZ
Variable MYVAR is a point with the same value of the measured centroid of LINE1 at the time of assignment.

ASSIGN/SVAR="Hello World"
Variable SVAR is a string with the value "Hello World"

In these examples, variables are being assigned values. Once a variable has been assigned a value, you can use the variable as an operand in any expression field.

Here, V1 is used in a numeric field. It is used as the prehit value of the prehit command:

ASSIGN/V1=1/3PREHIT/V1

Since expressions can be used in most editable fields, the following expression is also legal and has the same effect: PREHIT / 1/3.

The components of variables of type point can be referred to individually using the dot extension notation used for references.

ASSIGN/V1=MPOINT(3,4,5)
V1 is of type point with value of 3, 4, 5

ASSIGN/XVAR=V1.X
XVAR is of type double with the value of 3

ASSIGN/YVAR=V1.Y
YVAR is of type double with the value of 4

ASSIGN/IVAR=V1.I
IVAR is of type double with the value of 3

ASSIGN/REDUNVAR=V1.XYZ
REDUNVAR is of type point with the value of 3, 4, 5

The following extensions are equivalent to each other. Both are provided to clarify the meaning of an expression in a measurement routine.

Given that V1 is of type point.

V1.X is the same as V1.I
V1.Y is the same as V1.J
V1.Z is the same as V1.K

V1.XYZ is the same as V1.IJK and V1 without any extension.

If a variable of type string has a string value equal to the name of the id of a feature, dimension, or alignment, the variable can be used as a reference object:


ASSIGN/V1="CIRCLE1"

The following operands are possible and valid provided a feature with the name CIRCLE1 exists.

V1.X - The measured X value of CIRCLE1
V1.TX - The theoretical X value of CIRCLE1
V1.Diameter - The measured diameter of CIRCLE1
V1.Radius - The measured radius of CIRCLE1

This type of indirection available on string variables is only available to one level of indirection. The following will not work.

ASSIGN/V1="CIRCLE1"
ASSIGN/V2="V1"

V2.X - This will evaluate to 0 instead of the current measured value of CIRCLE1.X.

The reference V2.X will not be flagged as an error with red text even though an expression above it sets its type to a string. The reason it cannot be flagged as an error is because the flow of execution of the measurement routine is not known until execute time.

However, if you use curly brackets the following does work:

ASSIGN/V1={CIRCLE1}
ASSIGN/V2={V1}

V2.X - This will give you the value of CIRCLE1.X.

Consider the following example:

ASSIGN/V1="CIRCLE1"
ASSIGN/V2="V1"
IF/CIRCLE1.X>CIRCLE1.TX,GOTO,L2
L1=LABEL/
ASSIGN/V3=V2.X
GOTO/LABEL,L3
L2=LABEL /
ASSIGN/V2=MPOINT(2,5,7)
GOTO/LABEL,L1
L3=LABEL/

If during routine execution the value of CIRCLE1.X is greater than the value of CIRCLE1.TX, then the expression V2.X will be valid and will evaluate to 2. Otherwise, the expression V2.X will evaluate to 0 since the value of V2 at the time of the ASSIGN for V3 is the string "V1". It is the responsibility of the part programmer to ensure that expressions will do as expected in these cases.

Almost all of the feature references can be used on the left-hand side of the ASSIGN statement to put a value into a measured or theoretical data member of a feature. The only exception is the single I, J, K components of vectors. To assign to vectors, the complete vector must be assigned at once using an expression that evaluates to a point. Vector data is normalized as it is input into the feature’s vector data members.

ASSIGN/CIRCLE1.I=2-illegal
ASSIGN/CIRCLE1.IJK=MPOINT(2,0,0)-legal(vector is normalized to 1,0,0)

For information on using variables within dimensions, see the "Dimensioning Variables" topic in the "Using Legacy Dimensions" chapter.