##block/##endblock [ VIRTUOSO CODE GENERATOR Reference Manual ] MPE/iX 5.0 Documentation
VIRTUOSO CODE GENERATOR Reference Manual
#block/#endblock
Defines a scope for keywords defined between the #block and #endblock
construct.
Syntax
#block
.
.
statements
.
.
#endblock
Keywords
statements are statements or user text lines that will appear in
the same keyword scope.
Description
The #block/#endblock constructs define the scope of keywords introduced
in a section of text. Keywords introduced between the #block and
#endblock constructs are only accessible inside this scope. Outside the
scope, the keywords are not accessible. If a keyword is introduced in
the text before the #block statement is executed, the keyword is
accessible throughout the scope of the #block/#endblock and after the
#endblock.
When keywords introduced within the #block/#endblock must retain their
values outside of the current scope, the #returnvalue construct must be
used This construct allows values to be returned from the current scope
to the outer scope.
The #block/#endblock constructs allow some control over the stack usage
of the .
Nesting of #block/#endblock constructs is allowed, but note that the
nesting limit is 40. That is, there cannot be more than 40 nesting
levels in existence at one time. This includes nesting of #for/#endfor,
#if/#endif, #include, #block/#endblock, #entry/#endentry and macro calls.
Examples
EXAMPLE 1
#let element-name="PRODUCT-NUMBER"
.
.
#block
.
.
# getent element="!element-name" attr=(element-type byte-length)
.
.
#endblock
The above example illustrates the use of the #block/#endblock constructs
Between the #block and #endblock constructs the keywords element-type and
byte-length are accessible. Aft the #endblock, the keywords element-type
and byte-length are no longer accessible. Also note that the keyword
element-name is introduced outside the #block/#endblock scope, and is
therefore accessible inside t #block/#endblock scope as well as outside
this scope.
EXAMPLE 2
#block
.
.
# getrel module="!module" image-database=? relclass="processes"
.
# returnvalue image-database="!image-database"
.
.
#endblock
The above example illustrates the use of the #returnvalue construct to
return the value of the keyword image-database from the scope defined by
the #block/#endblock constructs. The value of the keyword image-database
is accessible following the #endblock statement.
EXAMPLE 3
The #block/#endblock construct can be used by programmers to create a
scope around any sequence of Virtuoso statements as long as it does not
overlap other constructs that define a scope. However, #block/#endblock
can contain other scopes. For example, you can nest a #for/#endfor
within a #block/#endblock.
This is an example of a valid #block/#endblock:
#block
#for...
...
#endfor
#endblock
This is an example of an invalid #block/#endblock:
#block
#for...
#endblock
#endfor
In the second case, the #block/#endblock and #for/#endfor overlap, and
overlapping scopes are not allowed.
MPE/iX 5.0 Documentation