Conditional Branching Instructions Conditional Branching Instructions Conditional branching instructions allow you to execute blocks of code based on the current values of program variables or expressions. eV+ has three conditional branch instructions: l IF...GOTO l IF...THEN...ELSE l CASE value OF IF...GOTO IF...GOTO behaves similarly to GOTO, but a condition can be attached to the branch. If the instruction: IF logical_expression GOTO 100 is encountered, the branch to label 100 occurs only if logical_expression has a value of true. IF...THEN...ELSE The basic conditional instruction is the IF...THEN...ELSE clause. This instruction has two forms:
IF expression THEN code block (executed when expression is true) END IF expression THEN code block (executed when expression is true) ELSE code block (executed when expression is false) END expression is any well-formed Boolean expression (described above). In the following example, if program execution reaches step 59 and num_parts is greater than 75, step 60 is executed. Otherwise, execution resumes at step 62. 56 . 57 ;CALL "check_num" if "num_parts" is greater than 75 58 59 IF num_parts > 75 THEN 60 CALL check_num(num_parts) 61 END 62 .
In the following example, if program execution reaches step 37 with input signal 1033 on and need_part true, the program executes steps 38 to 40 and resumes at step 44. Otherwise, it executes step 42 and resumes at step 44. eV+Language User's Guide, v2.x, 18318-000 Rev A Page 69