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

Re: Need XPL help



Reply to note from Russell Lewis  Mon, 15 Feb
1999 08:08:12 -0500 (EST)

-> Well, I finally got around to purchasing XY4 from the TTG along
-> with the XPL programming book. The XPL book is helpful but I
-> have a couple of questions for the group.

You realize, of course, that the XPL primer is strictly version 3 and
earlier -- has nothing to say about the many extensions introduced
with version 4. Even so, it barely covers the v3 rudiments, and
doesn't begin to hint at the underlying power. Take your first
question:

-> 1. I wish to write a program to put ">" marks at the
-> beginning of each line to quote a message. I have no
-> problem writing an XPL program to place a quote every time
-> I press a certain key. What I would like to do is to have
-> the program place quotes until it gets to the end of the
-> file and then quit. The "ER" function is not supposed to work
-> for this since it only returns values for commands, not
-> functions. Can anyone help me with this?

You need to test for the value of . It's 1 if the cursor is at
Bottom of File, 0 otherwise. Thus, <1> you're not there
yet.

-> 2. Along the same lines, I wish to be able to mark a block
-> text and put quote marks at the beginning of each line,
-> stopping when the end of the block is reached. I suppose
-> I could open a temp file, quote the text and replace the
-> orginal. But I was wondering if there was another way I
-> could do this.

There are at least a couple of ways to do this. If your procedure
doesn't require canceling the DeFine, then you can test for ,
the value being 1 if cursor is located withIN a DF block, 0 otherwise.
If you don't want to keep the DF block during execution, then save the
value of +1 -- the Define eNd position, plus 1 -- to a Save/Get
before canceling the DeFine: +1>. (Make sure the cursor
is *in text*, not on the CMline, when you grab this value.) Then move
the cursor to the beginning of the DF block, cancel the DeFine and
keep testing the cursor position until it's greater than the saved
value (i.e., has moved beyond the point where the DF block ended),
thus:

DB YD ≪PV01≫ [code that operates within DF block area] ;*;
 [you're out of the DF block area, so move on] ;*;

Note that  (along with its File Begin counterpart ) and
 were added in version 4.  and its Define Start
counterpart  were around before, but their behavior changed
significantly: in v4, if the cursor is on the CMline, these VAlues are
0, whether text is DeFined or not, so you've got to GT before testing
these values.

The XyWWWeb U2 file includes an exhaustive list of Xy4 VAlues and what
they mean. Install it, then command TABLE VA to review the
list.


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