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

Re: XPL advice required



Reply to note from Eric Van Tassel <101233.342@xxxxxxxx> Wed,
14 Apr 1999 02:15:00 -0400

-> As I work through successive drafts of a document, I'm trying
-> to work out a simple XPL routine to insert the word count at
-> the top of each new file. ... Here's the XPL as it stands ...
->
-> ≪SV901, words ≫≪SX01,≪VA$WC≫≫{ES}{TF}{SI}≪GT901≫
-> {BC}seba |words|{XC}≪GT01≫{TF}{BC}me \emq\header.prf{XC}≪EX≫
->
-> My problem is that this seems to work *sometimes*, but at other
-> times it produces a crazy word count -- sometimes 11 or 15,
-> sometimes 1 (the files are on the order of 600-800 words). And
-> even when it does work, it always inserts a smiley-face (ASCII
-> 1) right after the word-count figure.

Recall that  has a dual function: after a WC command, it
returns the Word Count; after a CHange command, the number of
changes. The problem with your routine is that you're not executing
a WC command before saving the VAlue of $WC. Those crazy "word
counts" are no doubt the results of the last search-and-replace
operation you performed! The solution is to move the cursor to TF
and execute BC wcXC (or BX wcQ2 , if you're in Xy4). Only then are
you ready to record )
as though it were a string. Use  (Put Value) instead of
, and the smiley-face problem will disappear. Alternatively,
you can re-save the number as a string, before GT'ing it:
. The advantage of the latter
approach is that text is not overwritten by the  even if
Overstrike mode is set (PV *will* overwrite text with Overstrike
on); so you can drop the Set Insert instruction (func SI) and leave
the typing mode wherever it happens to be.

Incidentally, there's no need for a "permanent" Save/Get (901) here.
You'll conserve memory by using a Save/Get in the 01-99 range
instead.

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