Code Sample of Else If / End Else If

Consider the following example that displays a message notifying the user when any one of the X, Y, or Z values for a measured point exceeds defined tolerances:

PNT2=FEAT/POINT,RECT
…
…
ENDMEAS/
IF/PNT2.X<6.9 OR PNT2.X>7.1
   COMMENT/OPER,"The measured X value of PNT2: " + PNT2.X + " is out of tolerance."
END_IF/
ELSE_IF/PNT2.Y<3.3 OR PNT2.Y>3.5
   COMMENT/OPER,"The measured Y value for PNT2: " + PNT2.Y + " is out of tolerance."
END_ELSEIF/
ELSE_IF/PNT2.Z<.9 OR PNT2.Z>1.1
   COMMENT/OPER,"The measured Z value for PNT2: " + PNT2.Z + " is out of tolerance."
END_ELSEIF/

Explanation of Sample Code

This code first tests the X value of the point. If the condition evaluates to false, then the code tests for the Y value. If the condition for the Y value evaluates to false, then it tests for the Z value.

If any of these conditions evaluates to true, PC-DMIS displays the comment associated with it and skips the remaining conditional statements.

IF/PNT2.X<6.9 or="" pnt2.x="">7.1
This line is the expression. It tests to see if the measured X value is less than 6.9 or greater than 7.1. If it exceeds either of these boundaries it executes the first comment.

END_IF
This line ends the execution of commands inside the IF / END IF block of code. Any command following this line is where PC-DMIS will go to if the IF THEN condition evaluates to false.

ELSE_IF/PNT2.Y<3.3 or="" pnt="" 2.y="">3.5
This line is the expression for the first ELSE_IF command. It only gets executed if the IF / END IF block above it returns false. It tests to see if the measured Y value is less than 3.3 or greater than 3.5. If it exceeds either of these boundaries it executes the second comment.

END_ELSEIF/
This line ends the execution of commands inside the first ELSE IF / END ELSE IF block of code.

ELSE_IF/PNT2.Z<.9 or="" pnt2.z="">1.1
This line is the expression for the second ELSE IF command. It only gets executed if the ELSE IF / END ELSE IF block above it returns false. It tests to see if the measured Z value is less than .9 or greater than 1.1. If it exceeds either of these boundaries it executes the third comment.

END_ELSEIF/
This line ends the execution of commands inside the second ELSE IF / END ELSE IF block of code.

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.