core

#### Code Sample of Do / Until

Consider the following example that measures a feature an amount specified by the measurement routine user. This is similar to the example given under the While / End While topic, except that PC-DMIS tests for the condition at the end of the loop instead of at the beginning.

C1= COMMENT/INPUT,Type the number of times PC-DMIS should measure the PNT1 feature:(type an integer only)

ASSIGN/COUNT=0

DO/

PNT1=FEAT/POINT,RECT

…

…

ENDMEAS/

ASSIGN/COUNT=COUNT+1

COMMENT/OPER,"Measured "+COUNT+" out of "+C1.INPUT+" times."

UNTIL/COUNT==C1.INPUT

Explanation of Sample Code

C1=COMMENT/INPUT

This line takes and stores the integer input from the user into the variable C1.INPUT.

ASSIGN/COUNT=0

This line initializes COUNT, a user-defined variable, and gives it an initial value of 0. The code uses this variable to count the number of times PC-DMIS measures the feature inside the loop.

DO/

Begins the DO / UNTIL loop. All statements are executed at least once and measurement routine flow exits out of the loop once the expression evaluates to false.

ASSIGN/COUNT=COUNT + 1

This line increments the COUNT variable by one so that it eventually exits the loop when it fails the condition test.

COMMENT/OPER,"Measured " + COUNT + " out of " + C1.INPUT + " times."

This line displays a message showing the number of times, out of the total, that the loop is running.

UNTIL/COUNT == C1.INPUT

This line ends the execution of commands inside the DO / UNTIL loop as long as the condition evaluates to false. Otherwise, when PC-DMIS encounters this command it loops back to the DO statement.