SirFact and comment-initialized globals

From m204wiki
Revision as of 21:42, 24 April 2017 by ELowell (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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