[Date Prev][Date Next][Subject Prev][Subject Next][ Date Index][ Subject Index]

XPL: Differences in Xy4|XyWin vs. Xy3



The following post to the Nota Bene list may be of interest here.

Reply to note from "Earls, JP"  Tue, 21 Mar 2000
11:24:17 -0600 (CST)

-> I have spent the good part of a morning trying to put carriage
-> returns in an NBW XPL file, trying all manner of combinations
-> of pfunc entries and program file recording. Imagine my
-> delight to discover that one need only hit the Enter key to put
-> in a carriage return.

I was chagrined to hear that this discovery consumed the better part
of an idyllic (or so I imagine it) Collegeville morning. The
confusion stems from NBWin's incorporation of "4th generation" XPL,
the raft of improvements introduced with the release of Signature
and XyWrite 4 in the early 1990's. It strikes me that, rather than
being condemned to repeat our mistakes, Notabenieri should benefit
from the nearly 10 years of experience XyWriters have had with this
much-improved programming environment.

Accordingly, there follows a list of some of the many improvements
to the programming language which are now available to Nota Bene
users with the release of NB for Windows:

Blind Execution of Commands: Instead of "BC command arg(s)XC " to
execute a command, use "BX command arg(s)Q2 ". There are several
important advantages. Any existing command line is preserved. The
command to be executed is no longer limited by the length of the
command line. And, because the command line isn't continually being
blanked and refreshed, programs execute faster and with a much
cleaner display.

SEarching is more powerful. To search for a carriage return (as you
found out at the expense of a late winter's morning), you simply put
it in the search statement: BX se /
/Q2 , though for readability it's preferable to use the carriage-
return "wildcard" character, produced by executing func WC. (Note
that you don't put "WC " in the search command; you execute func WC
to get the desired wildcard character.) To search for the Ascii-174
and -175 command delimiters, you can, again, insert the characters
themselves, but it's not advisable due to the likelihood of
unbalanced guillemets, which generate errors. Instead, use the
guillemet wildcards, generated by executing func ≪ (two "less
than's") and func ≫ (two "great than's") at the desired cursor
location.

The SEarch command has a number of new and useful switches.
SE/F |string| puts the cursor on the first letter of the found
string. SE/W |string| finds string only if it's a self-contained
word. SE/S |string| limits the search to selected text (DeFined
block). If the cursor is outside the block, the block is searched
from beginning to end. If the cursor is inside, the block is
searched from cursor location to the end of the block. SE/3
|string| finds the third instance of string (obviously, you can
substitute any number). All of these switches, except /F, apply as
well to CHange and Change-Verify commands. (CH and CI now work
identically, by the way.)

There are several new search wildcards, including one that enables
searches for this OR that. The OR wildcard is produced by executing
func NN, then hitting "O". Keyboard file assignment:
nn=NN,O

A number of new features make XPL code more readable and user-
friendly:

The comment symbol ;*; allows liberal inclusion of comments in
programs *without speed penalty*. The comment extends from the
comment symbol to the next carriage return, thus:

;*; First half of proverb

It's unnecessary to save text to a Save/Get in order to add it to an
existing Save/Get. Simply "quote" the additional text. Thus:

+" gathers no moss.">;*; Full proverb

You can echo the contents of a Save/Get to the PRompt line:

;*; Proverb is displayed on PRompt line

Note: Default MB must be set to 0. If default MB=1, the contents
will display in a Windows message box which will persist on the
screen until you press Enter or click on "OK". This causes problems
with programs that loop repeatedly through PRompt statements.

A PRompt may consist of text and a Save/Get number, as long as the
Save/Get number comes last:

;*; Proverb with prefatory remark

System VAriables and VAlues can be manipulated directly. It's no
longer necessary to save the VA to a Save/Get:

==0>;*; Test for open file

There are several extremely important extensions to the VA operator:

@siz() to get the length of a Save/Get is passe. Use .
@siz() crashes if Save/Get 01 is uninitialized; 
doesn't;
rather, it returns a value of -1 (useful information).

 tells you whether 01 contains a number (integer) or a
string. 1=number; 0=string

 provides important information about the status of Save/Get
01. If:

VA!01=0,  Save/Get 01 contains a string
VA!01=2,  Save/Get 01 contains SUbroutine
VA!01=4,  Save/Get 01 contains a numeric expression
VA!01=16, Save/Get 01 evaluates to FALSE
VA!01=24, Save/Get 01 evaluates to TRUE
VA!01=255, Save/Get 01 is not initialized

 returns the first 77 characters of Save/Get 01, the whole
Save/Get if the length is 77 or less. An extension to VA@ allows
easy
extraction of segments delimited by a separator. Suppose this:

;*; Data

Then =="Spring", =="Summer", etc.

There's a new Ascii-240 containment operator, which tersely reports
whether one string "contains" another. (The operator is the Ascii-
240 character itself, not the number in curly braces.) For example:

;*; Reports "Yes"
;*;
;*; Reports "No"

The epsilon containment operator works as before.

You can now time your programs. Func ZT ("Zero Time") resets the
timer to 0. The Elapsed Time is reported by . Here's how
you would time how long it takes to count to 10,000:

ZT ;*; Initialize 01 and reset timer
;*;
<10000>+1>;*; Count up
;*;
;*; Report elapsed
time

Speaking of counting, there's a nifty Count Up operator that makes
it easy to execute a segment of code a specified number of times.
Using it, the above code can be rewritten like this:

ZT NO ;*; Count Up
;*;
;*; Report elapsed
time

In the first line, everything between the  statement and LaBel
"a" () -- in this case, a simple func NO (No Operation) -- is
executed the number of times stated in Save/Get 01. CU requires two
elements, a delimiting LaBel name and a Save/Get which must contain
the desired number of repetitions. Note how compact the CU
formulation is. Also, if you translate the examples into live code
and run them, you'll see that CU is significantly faster (on my
machine, by a factor of 135%).

There are scores of new system VAriables which are highly useful in
XPL. With the XyWWWeb Jumbo U2 installed, you have easy access to
information about them with the command TABLE VAR.
Similarly, the many new functions can be viewed with TABLE
FUNC. (Helpkey is a key assignment that enables access to
XyWWWeb programs and help facilities. Details are in the
documentation.)

Finally, if you activate error suppression in a program
(BX es 1Q2 ), it's no longer necessary to turn it off at the end.
This happens automatically.

I hope this selective listing will ease your transition to the new
XPL.

--------------
Carl Distefano
CLDistefano@xxxxxxxx
http://users.datarealm.com/xywwweb/