omron — IF logical_expr GOTO program instruction

IF logical_expr GOTO program instruction IF logical_expr GOTO program instruction Syntax IF logical_expr GOTO label Function Branch to the specified step label if the value of the logical expression is TRUE (nonzero). Usage Considerations In general, it is a better programming practice to use the IF ... THEN control structure rather than this instruction. Parameters logical_expr Real-valued expression whose value is tested for TRUE (nonzero) or FALSE (zero). label Program step label of a step in the current program. Details If the value of the expression is nonzero, program execution branches and begins executing the statement with a label matching the one specified.

If the value of the expression is zero, the next instruction is executed as usual. If the specified statement label is not defined, the program is not executable. Any attempt to branch to an undefined label is identified when the program editor is exited and when the program is loaded into memory from a disk file. Example The most common use for IF...GOTO is as an exit-on-error instruction. The following code checks each I/O operation and branches to a label whenever an I/O error occurs: ATTACH(dlun, 4) "DISK" IF IOSTAT(dlun) 0 GOTO 100 FOPENW(dlun) "my_file" IF IOSTAT(dlun) 0 GOTO 100 ...

FCLOSE(dlun) "my_file" IF IOSTAT(dlun) 0 GOTO 100 DETACH(dlun) 100 IF IOSTAT(dlun) 0 THEN TYPE $ERROR(IOSTAT(dlun)) END eV+Language Reference Guide, v2.x, 18319-000 Rev A Page 291