Code Sample of Select / End Select

The pairs, SELECT / END_SELECT, CASE / END_CASE, DEFAULT CASE / END_DEFAULT CASE, all work together to evaluate multiple conditions providing a wide range of alternatives.

Suppose you have five circles, labeled CIR1 through CIR5, and you want the operator to be able to measure a circle by simply pressing a key on the keyboard. You could use code similar to the following:

Entire Code

DO/

C1=COMMENT/INPUT,Type a number to measure that circle:

,FOR CIR1 - Type 1

,FOR CIR2 - Type 2

,FOR CIR3 - Type 3

,FOR CIR4 - Type 4

,FOR CIR5 - Type 5

,Any other character exits the loop

SELECT/C1.INPUT

CASE/1

CIR1=FEAT/CIRCLE

ENDMEAS/

END_CASE

CASE/2

CIR2=FEAT/CIRCLE

ENDMEAS/

END_CASE

CASE/3

CIR3=FEAT/CIRCLE

ENDMEAS/

END_CASE

CASE/4

CIR4=FEAT/CIRCLE

ENDMEAS/

END_CASE

CASE/5

CIR5=FEAT/CIRCLE

ENDMEAS/

END_CASE

DEFAULT CASE

COMMENT/OPER,Now exiting loop.

END_DEFAULT CASE

END_SELECT

UNTIL C1.INPUT < 1 OR C1.INPUT > 5

Explanation of Sample Code

SELECT/C1.INPUT

This line of code takes a number or string value (in this case a number) typed by the user and determines which CASE/END_CASE block will execute from the input. Notice that SELECT/END_SELECT pair surrounds the entire list of code. All CASE/END_CASE and DEFAULT CASE/END_DEFAULT CASE pairs must reside within these two lines.

END_SELECT

This marks the end of the code held inside the SELECT/END SELECT pair.

CASE/1 through CASE/5

Depending on the value of C1.INPUT, one of the CASE code blocks executes. For example, if C1.INPUT evaluates to 1, the CASE 1 block of code executes, measuring CIR1. If it evaluates to 2, then the CASE 2 block of code executes, measuring CIR2, and so forth.

END_CASE

These lines end the specific case blocks of code.

DEFAULT CASE

If the value of the C1.INPUT doesn’t match any of the defined CASE statements (if the value isn’t a number one through five) then the DEFAULT CASE code block executes. In this case it displays a message letting you know that you are exiting the loop.

Notice how the DO / UNTIL loop surrounds the entire code sample. This allows the user to continue to choose from the menu created from the COMMENT/INPUT line until the user selects a character not recognized by the CASE statements.

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.