20.4.4 Including Symbolic Definitions
To enhance program development, BASIC allows you to use
symbolic definitions. Symbolic definitions are names or
symbols associated with values. These symbols are used in
many ways; the value associated with a symbol can be a sta-
tus code, a mask, or an offset into a data structure. Many
system routines depend on values that are defined in sep-
arate symbol definition files. For example, the status code
for successful completion has a value of one. However, this
code for successful completion is defined in the system library
(STARLET) as the symbol SS$_NORMAL.
A program might compare the status code returned by a sys-
tem service to either the symbolic constant SS$_NORMAL
or the integer value one. The program would execute the
same way in either case. In the first case, the value for SS$_
NORMAL is supplied at link time by the OpenVMS Linker.
In the second case, the value 1 is included in the program
as a literal constant. The advantages of using symbolic
definitions are as follows:
.
Because symbolic definition names are mnemonic, the
program is easier to read and understand.
.
It is easier to write the symbolic definition and let the
OpenVMS Linker fill in the value, than to look up the
value associated with the symbol and include that value
in the program.
.
Should the value associated with a symbol ever change,
you must relink the program. To change a hard-coded
definition, you must edit the source file, then recompile
and relink.
Symbolic definitions used by system services are located in the
default system library, STARLET.OLB.
For Run-Time Library routines, the only time that you need
to include symbolic definitions is when you are calling an
SMG$ routine, or when you are calling a routine that is a
jacket to a system service. (A jacket routine in the Run-Time
Library is a routine that provides a simpler, more easily used
interface to a system service.) If you call a routine in the
SMG$ facility, you must include the definition file SMGDEF.
All system services, however, require that you include SSDEF
to check status. Many other system services require other
symbol definitions as well.
To determine whether or not you need to include other sym-
bolic definitions for the system service you want to reference,
see the documentation for that service. If the documenta-
tion states that values are defined in the specified macro,
you must include those symbolic definitions in your program.
BASIC provides a text library that contains symbolic defini-
tions that can be accessed using the %INCLUDE directive. In
the following example, the definition file, SMGDEF is included
from the text library SYS$LIBRARY:BASIC$STARLET.TLB:
%INCLUDE "SMGDEF" %FROM %LIBRARY "SYS$LIBRARY:BASIC$STARLET.TLB"
For more information about including text libraries, see
Chapter 17.