Please enable JavaScript to view this site.

As an alternative to exposing all global variables to a function or procedure with AUTO_EXTERN, you can instead expose individual global variables via ++EXTERN statements:

++EXTERN SOME'VAR,F,6

++EXTERN SOME'ARRAY()

There are few subtleties and disclaimers to consider when using either of the above methods to declare specific global variables as being visible within a local procedure:

Declaring a variable with ++EXTERN or ++PRAGMA EXTERN_BEGIN does not have any effect on the original global variable definition, although it does allow the code within the procedure or function to modify the global variable at runtime.
The type and size may be omitted in the local extern declaration. Also, for arrays, the array dimensions may be omitted by just using (). However, if you do specify a type, size, or array dimensions, then they must match those in the original global definition of the variable. For example:

!(main program)

MAP1 GFLAGS(5),B,1

MAP1 SFLAG$,S,1

...

PROCEDURE TEST()

++EXTERN GFLAGS(5),B,1     ! valid

++EXTERN GFLAGS(5),F       ! invalid (types don't match)

++EXTERN GFLAGS(5),B,2     ! invalid (sizes don't match)

++EXTERN GFLAGS(4),B,1     ! invalid (subscripts don't match)

++EXTERN GFLAGS()          ! valid (equivalent to GFLAGS(5),B,1)

++EXTERN SFLAG$            ! valid (equivalent to SFLAG$,S,1)

 

The MAP level does not need to match (it doesn't even get specified for the ++EXTERN statements). But to the extent that there is any discrepancy between the local and global definitions, it is the global one that actually matters. The local one simply allows the local routine to access the global variable.

Another alternative to individual ++EXTERN statements is to use ++PRAGMA EXTERN_BEGIN and ++PRAGMA EXTERN_END to bracket some ordinary MAP statements (or a ++INCLUDE referencing more MAP statements), for example:

++PRAGMA EXTERN_BEGIN

MAP1 SOME'VAR,F,6

MAP1 ANOTHER'VAR,S,20

++INCLUDE MOREVARS.MAP

++PRAGMA EXTERN_END

 

Created with Help+Manual 9 and styled with Premium Pack Version 5 © by EC Software