++PRAGMA AUTO_EXTERN {"<boolean>"}
Enables or disables the visibility (with the local function or procedure) of variables defined globally—i.e. with standard MAP statements outside any function or procedure. The argument defaults to "TRUE", so the following are equivalent:
++PRAGMA AUTO_EXTERN "TRUE"
++PRAGMA AUTO_EXTERN
++pragma auto_extern ! pragmas are case insensitive
The setting is reset to FALSE at the start of each function or procedure, so must be specified whenever you want to reference global variables within a routine. The only point of specifying an argument of "FALSE" would be if you first enabled it, then later in the function didn't have any further need to reference global variables and wanted to protect against accidentally doing so.
Example
PROCEDURE MYPROC(p1 as f)
++PRAGMA AUTO_EXTERN ! expose all global vars to this procedure
...
SOME'VAR = SOME'VAR + p1 ! add parameter p1 to global variable SOME'VAR
...
ENDPROCEDURE
The above technique, while undermining one of the benefits of using PROCEDURE as opposed to old-style GOSUBs, does provide a convenient way to migrate from unstructured GOSUBs to structured PROCEDURES. Essentially all you need to do to convert a reasonably well-designed GOSUB into a proper PROCEDURE is to add the PROCEDURE keyword, an empty parameter list, the AUTO_EXTERN pragma, remove the RETURN, and add the ENDPROCEDURE, e.g.
The following GOSUB ...
MYPROC:
...
RETURN
can be converted to a PROCEDURE as follows:
PROCEDURE MYPROC()
++PRAGMA AUTO_EXTERN
...
! RETURN ! (RETURN may also be converted to EXITPROCEDURE)
ENDPROCEDURE
Note that the above illustration ignores certain issues that may complicate such conversions. If the GOSUB has RETURN statements other than at the physical end, these can be converted to EXITPROCEDURE statements. But a PROCEDURE may not contain GOSUB (or CALL) statements to other old-style GOSUB routines, so they would have to be converted as well. Also, any GOSUB MYPROC (or CALL MYPROC) statements referencing the original routine would have to be converted to CALL MYPROC. These are all fairly mechanical steps though, after which you would be in position to incrementally access the modularization/isolation/encapsulation advantages of proper procedures with local variables and true parameter passing.
See Also