The body of code between the braces is the procedure code, and it differs from traditional ObjectScript code in the following ways:
-
A procedure can only be entered at the procedure label. Access to the procedure through label+offset syntax is not allowed.
-
Any labels in the procedure are private to the procedure and can only be accessed from within the procedure. The PRIVATE keyword can be used on labels within a procedure, although it is not required. The PUBLIC keyword cannot be used on labels within a procedure — it yields a syntax error. Even the system function $TEXT cannot access a private label by name, although $TEXT does support label+offset using the procedure label name.
-
Duplicate labels are not permitted within a procedure but, under certain circumstances, are permitted within a routine. Specifically, duplicate labels are permitted within different procedures. Also, the same label can appear within a procedure and elsewhere within the routine in which the procedure is defined. For instance, the following three occurrences of Label1 are permitted:
Rou1 // Rou1 routine
Proc1(x,y) {
Label1 // Label1 within the proc1 procedure within the Rou1 routine
}
Proc2(a,b,c) {
Label1 // Label1 within the Proc2 procedure (local, as with previous Label1)
}
Label1 // Label1 that is part of Rou1 and neither procedure
-
If the procedure contains a DO command or user-defined function without a routine name, it refers to a label within the procedure, if one exists. Otherwise, it refers to a label in the routine but outside of the procedure.
-
If the procedure contains a DO or user-defined function with a routine name, it always identifies a line outside of the procedure. This is true even if that name identifies the routine that contains the procedure. For example:
ROU1 ;
PROC1(x,y) {
DO Label1^ROU1
Label1 ;
}
Label1 ; The DO calls this label
-
If a procedure contains a GOTO, it must be to a private label within the procedure. You cannot exit a procedure with a GOTO.
-
label+offset syntax is not supported within a procedure, with a few exceptions:
-
$TEXT supports label+offset from the procedure label.
-
GOTO label+offset is supported in direct mode lines from the procedure label as a means of returning to the procedure following a Break or error.
-
The ZBREAK command supports a specification of label+offset from the procedure label.
-
When the procedure ends, the system restores the $TEST state that had been in effect when the procedure was called.
-
The } that denotes the end of the procedure can be in any character position on the line, including the first character position. Code can precede the } on the line, but cannot follow it on the line.
-
An implicit QUIT is present just before the closing brace.
-
Indirection and XECUTE commands behave as if they are outside of a procedure.