SirFact and comment-initialized globals: Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (misc cleanup)
 
No edit summary
 
(3 intermediate revisions by 3 users not shown)
Line 20: Line 20:
and statements; it also reduces GTBL requirements.
and statements; it also reduces GTBL requirements.


If you want to insert various statements (for example, <var>[[SirFact statements#The Assert statement|Assert]]</var> statements) in your <var class="product">SOUL</var>
If you want to insert various statements (for example, <var>[[SirFact SOUL statements#Assert statement|Assert]]</var> statements) in your <var class="product">SOUL</var>
applications, leaving them disabled until a global variable is reset,
applications, leaving them disabled until a global variable is reset,
you can use a backslash global as the first character of the statement.
you can use a backslash global as the first character of the statement.
Line 35: Line 35:
This prefixing technique can also be useful in many applications other than <var class="product">SirFact</var>.
This prefixing technique can also be useful in many applications other than <var class="product">SirFact</var>.
<p class="note"><b>Note:</b> To have the initial value of backslash globals
<p class="note"><b>Note:</b> To have the initial value of backslash globals
become the null string, set the X'04' bit of the <var>[[SirFact system parameters#The SIRFACT parameter|SIRFACT]]</var> system parameter to 1.
become the null string, set the X'04' bit of the <var>[[SirFact system parameters#SIRFACT parameter|SIRFACT]]</var> system parameter to 1.
With this bit setting, global variables whose names start with a
With this bit setting, global variables whose names start with a
backslash are treated the same as any other global variable.
backslash are treated the same as any other global variable.

Latest revision as of 21:42, 24 April 2017

In addition to the SIRFACT command, the SirFact parameters, the SOUL statements for SirFact, and the SirFact $functions, the following global-variable feature is available in the Model 204 nucleus when SirFact is authorized.

Comment-initialized global variables

If a global variable begins with the backslash character (\), its initial value, (that is, the value if the variable does not have a value) is a single asterisk (*) when used for dummy string substitution (?&). These are also called backslash globals. The initial value for backslash globals returned by the $Getg function is unaffected by this feature (that is, the initial value is the null string).

Backslash globals are provided primarily to allow you to place Model 204 commands and SOUL statements in your applications under the control of a backslash global; these commands and statements are disabled unless the global is set to the null string (or some other non-asterisk value). This approach is more convenient than having to explicitly set the global variables to an asterisk in order to disable the commands and statements; it also reduces GTBL requirements.

If you want to insert various statements (for example, Assert statements) in your SOUL applications, leaving them disabled until a global variable is reset, you can use a backslash global as the first character of the statement.

For example, the following Assert statement is disabled by default:

?&\INPCHK ASSERT %INPUT GT 0

But the statement can be enabled by:

BEGIN %X = $SETG('\INPCHK', ) END

This prefixing technique can also be useful in many applications other than SirFact.

Note: To have the initial value of backslash globals become the null string, set the X'04' bit of the SIRFACT system parameter to 1. With this bit setting, global variables whose names start with a backslash are treated the same as any other global variable.

See also