Code Sample of While / End While

Consider the following example that measures a feature an amount specified by the measurement routine user.

C1=COMMENT/INPUT,How many times would you like to measure PNT1? Please type an integer only.

ASSIGN/COUNT=0

WHILE/COUNT<C1.INPUT

PNT2=FEAT/POINT,RECT

ENDMEAS/

ASSIGN/COUNT=COUNT+1

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

END_WHILE/

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.

WHILE/COUNT<C1.INPUT

This line is the expression. It tests to if the value of COUNT (initially set to 0) is less than the integer selected by the user. If this tests true, then the statements in following WHILE/ and before END_WHILE/ are executed

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.

END_WHILE

This line ends the execution of commands inside the WHILE / END WHILE block as long as the condition is false. Otherwise, when PC-DMIS encounters this command it loops back to the WHILE statement.

Command Mode Commands after Comments

After you insert a PC-DMIS comment, to type additional PC-DMIS commands in Command mode, you must first press Enter twice after the COMMENT command. This tells PC-DMIS that you no longer want to add text to the comment but are ready to add a new command.