core

### Pointers

Pointers are also known as "Feature Pointers ". See the Glossary term "Feature Pointers" for more information.

Pointers provide a way to reference a feature via a variable or to pass objects using the call sub command. Pointers are similar to indirection via string names. However, the advantage of using pointers is with subroutines. Pointers, unlike strings, when passed in as arguments of a subroutine, allow for direct modification of the object pointed to by the subroutine. Pointers are not used in complex expressions. If it is used in a complex expression, the pointer evaluates to zero.

Consider the following examples.

Pointer Use Example:

- ASSIGN/V1={CIR1}

V1 is now a pointer that points to CIR1.

- ASSIGN/DIST=DOUBLE(V1.XYZ)

Dist = distance of CIR1 from origin.

You can also put an expression between curly brackets in order to obtain a feature pointer. Now the following examples are all legal ways to get the pointer to feature CIR1:

- ASSIGN/FEATCOUNT=1
  ASSIGN/V1={"CIR"+FEATCOUNT}

Assigns expression "CIR1" to V1.

- ASSIGN/V2="CIR1"
  ASSIGN/V3={V2}

Assigns expression "CIR1" from variable V2 to variable V3.

- C1=COMMENT/INPUT,Please type a feature name.
  ASSIGN/V4={C1.INPUT}

This takes the feature name of C1.INPUT and places it into variable, V4.

Subroutine Example:

In the calling routine:

CS1=CALLSUB/SUB.PRG,CHANGEX,{CIR1}

In the subroutine:

GEN1=GENERIC/FEATURE
SUBROUTINE/CHANGEX,ARG1={GEN1}

(When CIR1 is passed in it takes the place of GEN1)

ARG1.X=5

(Sets the measured X value of CIR1 to 5)

END/SUBROUTINE

Complex Expression Example:

ASSIGN/V1={CIR1}+2

{CIR1} evaluates to zero and so entire expression evaluates to 2.