beautypg.com

Compaq DEC Text Processing Utility AA-PWCBD-TE User Manual

Page 97

background image

Lexical Elements of the DEC Text Processing Utility Language

4.9 Reserved Words

Syntax

LOCAL variable-name [[,...]];

Local variables may also be declared in unbound code. Such variables are
accessible only within that unbound code.

Unbound code can occur in the following places:

Module initialization code

This occurs after all procedure declarations within a module but before the
ENDMODULE statement.

Executable code

This occurs after all module and procedure declarations in a file but before
the end of file.

The following example shows a complete compilation unit. This unit contains
a module named mmm that, in turn, contains a procedure bat and some
initialization code mmm_module_init, a procedure bar defined outside the module,
and some unbound code at the end of the file. In each of these sections of code, a
local variable X is defined. The variable is displayed using the MESSAGE built-in
procedure.

MODULE mmm IDENT "mmm"

PROCEDURE bat;

! Declare procedure "bat" in module "mmm"

LOCAL

X;

! "X" is local to procedure "bat"

X := "Within procedure bat, within module mmm";

MESSAGE (X);

ENDPROCEDURE; ! End procedure "bat"

LOCAL

X;

! "X" is local to
! procedure "mmm_module_init"

X := "Starting or ending the module init code";
MESSAGE (X);
bat;
MESSAGE (X);

ENDMODULE;

! End module "mmm"

PROCEDURE bar

! Declare procedure "bar"

LOCAL

X;

! "X" is local to procedure "bar"

X := "In procedure bar, which is outside all modules";
MESSAGE (X);

ENDPROCEDURE;

! End procedure "bar"

LOCAL

X;

! "X" is local to the unbound code...

X := "Starting or ending the unbound, non-init code";
MESSAGE (X);
mmm_module_init;
bat;
bar;
MESSAGE (X);
EXIT;

Lexical Elements of the DEC Text Processing Utility Language 4–31