TAL Reference Manual
Compiler Directives
TAL Reference Manual—526371-001
16-78
Examples of SAVEGLOBALS Directive
Examples of SAVEGLOBALS Directive
1. The following source file (MYPROG) is compiled in examples 2 through 5, which
show how the SAVEGLOBALS, USEGLOBALS, BEGINCOMPILATION, SEARCH,
and SYNTAX directives interact:
!Source file MYPROG
!Unless USEGLOBALS (examples 3 and 5) is in effect,
! compile the entire source file.
?SOURCE glbfile1 (section1, section2)
?SOURCE moreglbs
INT ignore_me1;
INT ignore_me2;
?BEGINCOMPILATION !When USEGLOBALS is in effect,
! compile code that follows.
?PUSHLIST, NOLIST, SOURCE $system.system.extdecs
?POPLIST
PROC my_first_proc;
BEGIN
!Lots of code
END;
PROC my_last_proc;
BEGIN
!More code
END;
2. A SAVEGLOBALS compilation compiles MYPROG and saves global data
declarations in file TALSYM and global initializations in object file MYOBJ:
TAL /IN myprog/ myobj; SAVEGLOBALS talsym
3. A USEGLOBALS compilation then produces object file NEWOBJ and retrieves
global data declarations from TALSYM and global initializations from MYOBJ.
When USEGLOBALS is in effect, the compiler ignores text lines and SOURCE
directives until BEGINCOMPILATION appears in the source file:
TAL /IN myprog/ newobj; USEGLOBALS talsym, SEARCH myobj
4. Alternatively, you can place the preceding SEARCH directive in the source file
anywhere before the BEGINCOMPILATION directive. You can check the syntax of
global data declarations before saving them:
TAL /IN myprog/; SAVEGLOBALS talsym, SYNTAX