Syntax errors are errors which are reported when translating a procedure. (Other errors can occur while youre running a program.) The OPL translator will return you to the line where the first syntax error is detected.
All programming languages are very particular about the way commands and functions are used, especially in the way program statements are laid out. Below are a number of errors which are easy to make in OPL. The incorrect statements are in bold and the correct versions are on the right.
Omitting the colon between statements on a multi-statement line:
Incorrect |
Correct |
a$="text" PRINT a$ |
a$="text" :PRINT a$ |
Omitting the space before the colon between statements:
Incorrect |
Correct |
a$=b$:PRINT a$ |
a$=b$ :PRINT a$ |
Omitting the colon after a called procedure name:
Incorrect |
Correct |
PROC proc1: GLOBAL a,b,c . proc2 ENDP |
PROC proc1: GLOBAL a,b,c . proc2: ENDP |
Using only 1 colon after a label in GOTO/ONERR/VECTOR (instead of 0 or 2):
Incorrect |
Correct |
GOTO below: . below:: |
GOTO below . below:: |
The DO...UNTIL, WHILE...ENDWH and IF...ENDIF structures can produce a Structure fault error if used incorrectly:
Attempting to nest any combination of these structures more than eight levels deep will produce a Too complex error.