[Date Prev][Date Next][Subject Prev][Subject Next][
Date Index][
Subject Index]
Defaults in XPL
- Subject: Defaults in XPL
- From: "Carl L. Distefano" 70154.3452@xxxxxxxx
- Date: 05 May 95 11:23:00 EDT
Myron:
My practice regarding defaults is to change only the values
needed by the program, and to leave everything else alone. The
less tampering with system VAriables, the more compact the code
and the less opportunity for unintended mischief. Therefore, I
don't much like the idea of a canned
"preamble" to every program, and would not recommend using one.
When setting and restoring variables is necessary, the basic
procedure is to "SX" the value to a save/get, set the desired
value, and then restore the original value by executing the
appropriate DEFAULT (D) command at the end of the program. For
example, to set default NW (New Window) to 0, then reset the
original value:
Example (1)
{SX01,{vanw}}BC d nw=0XC ... BC d nw={PV01}XC
To set/reset more than one variable, you can take advantage of
the DEFAULT command's ability to handle multiple variables. The
following code sets/resets NW and EB (Error Beep)
Example (2)
{SX01,{vanw}}{SX02,{vaeb}}BC d nw=0,eb=0,0XC ... BC d
nw={PV01},eb={PV02}XC
When resetting multiple defaults in XyIII+, make sure the D
command fits on the command line! If it doesn't, break it up
into two or more commands.
The string-literal concatenations enabled in Xy4 make it
practical to save all default values to a single subroutine
(minimizing save/get usage), and to restore those values on EXit
simply by executing that subroutine. The following adapts
Example (2) above:
Example (3)
{SX01,{vanw}}{SX02,{vaeb}}{SX01,"BX d
nw="+{is01}+",eb="+{is02}+"Q2 "}BX d nw=0,eb=0,0Q2 ...
{PV01}{EX}
One great advantage of the Blind Execute (BX) function in Xy4 --
the other and obvious advantage being that it doesn't obliterate
the command line -- is greatly increased speed of execution. On
my antediluvian 386/20 system,
100 iterations of Example (2) above (minus the ellipsis) takes
about 12 seconds, whereas 100 iters. of Example (3) takes about
2.5 seconds.
That's almost five times faster!
Also, although Example (3) happens to change Error Beep, in Xy4
you don't have to zero out EB to avoid unwanted beeps: just
command BX (es 1). In other words, the numerous bugs associated
with error suppression in XyIII+ have been fixed. You don't even
have to reset ES to 0; this happens automatically when the
program is done. In Xy4, Error suppression plus frozen display
(func DX) yields fast, smooth execution. (DX in XyWin is another
story.)
My standard "preamble" for Xy4 programs is "XH BX (es 1)DX ..."
(Cancel any
Help menu, turn on Error Suppression, Freeze the Display).
Unless the program requires more, that's *all* I do. For some
further thoughts on defaults in XPL, see "A Word about Defaults",
in SMARTSET.NTS
[SMARTS24.ZIP].
I see I've rattled on too long.
--------------
Carl Distefano
70154.3452@xxxxxxxx