[Date Prev][Date Next][Subject Prev][Subject Next][
Date Index][
Subject Index]
Re: XY4 programming
- Subject: Re: XY4 programming
- From: cld@xxxxxxxx (Carl Distefano)
- Date: Thu, 13 Jun 2002 22:38:41 -0400
Reply to note from "Morris Krok" Thu, 13 Jun
2002 09:28:37 -0700
Morris:
> Has Carl or Robert written a short programming manual on Xy4
> that extends what is found in the Xy4 Customization Guide. I
> will; have no problem printing such a guide.
Nothing comprehensive, alas. The XyWWWeb site includes links to
several monographs on XPL-related subjects. Most were written for
Xy3, but some, notably CTRLCHAR.TXT, delve into fundamentals that
still apply in Xy4 and later. And there's BX.TXT (available at
http://users.datarealm.com/ammaze/xfer/bx.zip), a tutorial on using BX..Q2
to execute commands in v4+.
I wouldn't bother trying to print out these files. Many of the
special characters they discuss don't easily translate into
printable characters, or simply won't print at all. When you come
right down to it, tutorials of this kind deliver their best value in
electronic form.
For what it's worth, here is a summary of XPL v4 features that I
posted to the Nota Bene mailing list a couple of years ago:
-------
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: In NotaBene, 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 ["" is the Ascii-21 Section symbol.]
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 Ascii-238 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.)
The range of "permanent" (memory-resident) Save/Gets is increased to
100-1999. (In Xy3|NB4 it was 100-999.) All are available to users,
although many Save/Gets in the 1000-1999 range are reserved for use
by the manufacturer and for third-party developers.
Finally, if you activate error suppression in a program:
BX es 1Q2 ;*;
it's no longer necessary to deactivate it (BX esQ2 or BX es 0Q2 ) at
the end. This happens automatically.
-------
--
Carl Distefano
cld@xxxxxxxx
http://users.datarealm.com/xywwweb/