Apropos of nothing in particular, it is possible to write a single
XPL program that's optimized for both Xy4+ and Xy3. The key is to
determine what version of XyWrite (or NotaBene) the user is running,
using a method that's compatible with both Xy3 and Xy4. In Xy4 and
later, this is easy: returns the version number. However,
isn't available in Xy3. What to do? Consider this:
)"">NO >
(In the above pseudo code, "<" and ">" are guillemets and "(>)"
represents the "greater than" symbol.)
The major version number, 3 or 4, is now in Save/Get 01. I'll
describe later *how* it works. The point here is *that* it works.
That is, after this code executes, the program is "version smart":
it can determine for itself whether it's running under Xy3 or 4.
This means that code can be optimized within the program. For
example, the program can determine whether to execute commands with
BX...Q2 or BC...XC:
(>)3>
Now, to execute a command, you'd write not BC commandXC or
BX command Q2 but command, automatically invoking the
method appropriate to the underlying environment (3 or 4).
More generally, what this means is that a single program can be
written in segments that are alternately v3-compatible, v4-
compatible and compatible-with-both-versions, and instructed to
branch to the appropriate segments depending on the version number.
An example of this sort of writing can be found in the Jumbo U2
routine called DEFORMAT.
How does the version test work? The key is SUbroutine 02. In plain
English, it tests for the truth of the statement `the string "x" is
bigger than "" (the null string)'. The statement is, of course,
true; the point here is not truth or falsity, but the method used to
make the statement, i.e., direct quotation of the strings "x" and ""
without first saving them to Save/Gets. Direct quotation works in
Xy4 but crashes in Xy3; it thus acts as a litmus test. If
SUbroutine 02 crashes, it never reaches the instruction ,
and the value of Save/Get 01 remains 3, as originally set. Save/Get
01 thus accurately reflects the major version number, 3 or 4.
Q.E.D.
Note that the version test, which depends on a crash, has to be in a
SUbroutine to avoid crashing the whole program. It should be
prefaced with BC es 1XC , to suppress a beep if the crash happens.
That initial ES 1 command *has* to be executed with a least-common-
denominator BC...XC (not BX...Q2 ) because, at that point, we don't
know whether we're operating in version 3 or 4. For the same
reason, the SUbroutine must end with a v3-specific func NO (absent
another apt function), even though this can be dispensed with in v4.
--
Carl Distefano
cld@xxxxxxxx
http://users.datarealm.com/xywwweb/