[Date Prev][Date Next][Subject Prev][Subject Next][
Date Index][
Subject Index]
2 SPACES
Since we're all having such fun with converting sentence endings
to 2 spaces, here's another variation (for Xy 4). I didn't like
the number of cursor moves in my original; nor did it account for
numerals such as 10.2. In addition, I received a note from Carl
pointing out a loop the original went into.
I got it to loop too! (Thank heavens for Ctrl+Break, the
programmer's friend!)
Anyway, the new version reduces cursor moves in favor of
extracting string information via XS. The only caution is that
sentences ending on an alphabetic acronym (such as ABC) would be
skipped if the letter list wasn't somewhat scrambled.
Basically, the problem is somewhat dull, but the solution does
allow one to play with different aspects of XPL. For instance,
the sequence F1 CL F1 {sv##} is okay, but the va obtained at the
end of a file via $RS can generate a program-killing error.
Well, I tried LB_ instead of LB-, but it can generate more
unfortunate end-of-line breaks. Either that or I'm just too
automatic. However, in terms of paper copy, in which breaks can
be controlled, I'm sure the underscores would be better.
This version runs somewhat slower than the previous; but it
should be more accurate. Perhaps someone can tell me how to
combine BX commands with wildcards in a search??
------------------------------------------------------
{LB-space2.pm, for Xy4, to add two spaces after a sentence, by
Chet}DX {GL-var}
I liked Carl's use of XS, which is more efficient than cursor
moves. Easier to get the information I wanted, so the variables
are somewhat rearranged. Note that sv60 and 70 are Escape +
(capital!) character for the wildcard equivalent.
{LB-var}{SV05,?}{SV10, }{SV12, }{SX17,0}{SV20,
}{SV41,ABCDEFGHIJKLMNOPRSTUVWXYZ}{SV42,Mr.Mrs.Ms.Jr.Dr.Prof.}
{SV43,0123456789}{SV60,?S}{SV70,?A}{SU95,BC DO }{GL-mainloop}
{LB-mainloop}GT NS DF CR DF CL {SV17}XD {IF({IS17}<{IS05})}
{GL-end}{EI}{SX17,@UPR({IS17})}{GL-where}
I tried the va to read the character under the cursor, but it can
generate an error at the end of the file. The above code is more
tedious, but should work in Xywin which lost that va. The if
above is that if the define is less than an ascii 1, it is a
nonexistent define. Surely there is an easier way to do this?
The heart of the search to define from the first letter of the
last word of the sentence to the last letter of the first word of
the sentence. That area has all the information we want.
Again note, epsilon is represented by a lowercase e for comparing
is" expressions.
{LB-where}{IF({IS17}e{IS41}=>0)!({IS17}e{IS43}=>0)}
{GL-mainloop}{EI}{GL-search1}
{LB-search1}BC seb /WS WA /XC {IF{ER}}{GL-abort2}{EI}CR DF NS
{GL-search2}
The below search is not absolutely necessary, but it allows a
better end to a program than comparing cursor position, which can
be confounded in a long file.
{LB-search2}BC se /WA WS /XC {IF{ER}}{GL-end}{EI}CL DF {SV77}XD
{GL-word}
{LB-word}{IF({IS12}e{IS77}=>0)!({IS20}e{IS77}=>0)}
{GL-mainloop}{EI}{GL-break}
The two XSs below extract all our information: 72 becomes the
first letter of first word and 61 is the entire last word.
{LB-break}{XS77,60,61,62,63}{XS63,70,71,72,73}{GL-cap}
If first letter is a cap, check previous word.
{LB-cap}{IF({IS72}e{IS41}=>0)}{GL-ask}{EI}{GL-mainloop}
If previous word is an initial cap or an abbreviation, return to
main loop. Could be a problem with alphabetic acronyms. Perhaps
scramble the order of 41.
{LB-ask}{IF({IS61}e{IS41}=>0)!({IS61}e{IS42}=>0)}
{GL-mainloop}{EI}{GL-place}
One of my few BXs below. I have no luck with 'em when combined
with wild characters; but it works fine with text.
{LB-place}BX seb / /Q2 {IF{ER}}{GL-abort1}{EI}{PV10}{GL-mainloop}
{LB-abort1}{GT95}{PRUnexpected missing space--aborted}{EX}
{LB-abort2}{GT95}{PRNothing at start of file?}{EX}
{LB-end}XD {GT95}{PRFinished, more or less}{EX}
--Chet
---
? SLMR 2.1a ? Art + write + dtp = chet.gottfried@xxxxxxxx