[comp.os.cpm] Query: WS continuous underline

binder%fizbin.DEC@decwrl.dec.com (Sold - but we have others) (12/30/86)

Jay Bowden asks:

> WordStar question: How can you get the underline to fill the spaces between
> words?  I have wanted to do this from time to time myself, but always come
> up empty handed, and just put up with the way WS does it.  She can not;
> there is some peculiar nursing journal format she has to conform to.  I've
> wondered about the non-break-space, but that's such a pain!  Any easy
> answers? 

There are two ways that I know of to accomplish what you want.  

First, of course, is to use the non-break space, but I agree that it's a pain.

The second way assumes that your printer (your sister's, actually) has a 
command code to turn on continuous underline.  If that is the case, there is a 
WS patch called ANYCODE that will do what you want.  The original ANYCODE was 
created by Doug Hurst.  I rewrote it to handle what I felt were two very 
severe limitations it had - my version is called ANYCODE2, and it is upward 
compatible with Doug's ANYCODE.

ANYCODE2 uses two characters as flags to initiate special sequences.  

1.  A back accent (" ` ", hex 60) will cause ANYCODE2 to collect the next two
    characters, which must be valid hex-ASCII characters (0123456789ABCDEF)
    and convert them into a single ASCII character for transmission.  For
    example, this sequence: 

	whatever text `0Fexpanded text`12 some more text

    will cause the words "expanded text" to be printed double-wide on an Epson
    printer.  The `0F is an ASCII <SI> and the `12 is a <DC2>. 

2.  A tilde (" ~ ", hex 7E) will cause the same action except that an <ESC>
    will be transmitted FIRST, before the constructed character.  For example,
    this sequence:

	~4E`08

    will transmit <ESC> N <BS> which will cause an Epson printer to set for
    an eight-line perforation skip between pages.  You could do the same
    thing this way:

	`1B`4E`08

    but using the tilde is more convenient.

ANYCODE2 allows you to use lowercase characters in your code sequences, so 
that `4e will be read the same as `4E.  It also allows you to print the two 
special leadin characters by repeating them - this sequence:

	an ``enclosed' word

will print as:

	an `enclosed' word

ANYCODE2 is in 8080 code and can be assembled and installed into WS using DDT 
under CP/M.  It goes into a special patch area provided and does not increase
the size of the WS.COM file. 

To do continuous underlining, create your WS file as you want it, and then go 
back and, with margin release set, insert the code sequences to turn 
continuous underlining on and off.  You can do this very easily by creating a 
text block containing one sequence, plant it everywhere you want it, and then 
create another block for the second sequence.  You have to do all the 
justification and so forth that you want BEFORE inserting the code sequences, 
because WS sees these sequences as "real" characters in the file.

I don't have a way to upload ANYCODE2 to a BBS anywhere - no serial line on my 
home machine.  If there is interest in ANYCODE2, send email to me, and I'll
bring a copy of the source listing to work and type it in for upload or
posting. 

Cheers,
Dick Binder   (The Stainless Steel Rat)

DEC Enet:	ASD::BINDER
UUCP:		{ decvax, allegra, ucbvax... }!decwrl!asd.dec.com!binder
ARPA:		binder%asd.DEC@decwrl.ARPA

W8SDZ@SIMTEL20.ARPA (Keith Petersen) (01/02/87)

The following is from WSUNDERL.TXT, available in our software library
as PD:<CPM.WSTAR>WSUNDERL.TQT.

           Underlining in WordStar with a Dot Matrix Printer

Here's how to set WordStar up so that it will give you continuous
underlining (rather than the broken dash kind) whenever you want it.  I
shall use WordStar 3.3 as the example (the drill for version 3.0 is
somewhat different).  What you have to do is pick out one of the Printer
Codes for which you have no use and redefine it so that it will toggle
continuous underlining on and off.  A suitable one is the ^PY that
WordStar provides for changing your ribbon color, which you are unlikely
to mind giving up.  And you can make the change, by running either
WINSTALL or DDT.  I'll describe the former method, because most people
probably have some acquaintance with it.  <CR> means: enter a Return.

As a safety precaution make a copy of your present WordStar file, and
then work on that copy.  Then, if things go wrong, you still have your
original WordStar file safe and sound.  A simple way to do that is to
rename the file with:

A>ren oldws.com=ws.com  <CR>
A>pip ws.com=oldws.com  <CR>

Now work exclusively with WS.COM.  Start by passing through the early
screens of WINSTALL until you reach the Installation Menu, where you
again choose between two methods of achieving your goal.  I shall
describe the shorter and quicker one.

At the Installation Menu you are invited to select one of several
letters.  Don't take any of them.  Instead do something that you are not
told about at all - hit the "+" key.

1. This will bring up a screen called "Custom Modification routine".
Hit <CR>.

2. You will be asked for a starting address.  Reply by entering the
label:

        :RIBBON     [You must start with that colon]

3. You will be told you are at address 6E3h.  ["h" is not part of the
address; it indicates that the numerals, like all the numerals in this
operation, are in hexadecimal notation.]  And below will be a row of 16
numerals.  You will be asked if this is OK.  It is, so enter Y.

4. The next screen may look terrifying, if you have not been in this
sort of country before.  Not to worry.  Just follow these instructions
blindly - but with your eyes wide open, to make sure that you enter
things exactly as below.

Where the cursor is flashing enter:

        ,03   <CR>   [Put that comma in each time]
        ,1B   <CR>
        ,2D   <CR>
        ,31   <CR>
        .     <CR>   [No comma that time.  Just the period]

5. Then enter <CR> to continue, and repeat the pattern of 2.- 4. above,
but entering different values.  This time give as your starting address:

        :RIBOFF           [Don't forget that colon]

6. You will be told you are at address 6E8h.  That is OK, so type Y.

7. Now the values to be entered at the cursor are:

        ,03   <CR>
        ,1B   <CR>
        ,2D   <CR>
        ,30   <CR>
        .     <CR>

8. Next type X to leave the Modification routine.

   Then type X again to leave the Installation Menu.
   Then type A to save the changes you have made.

** NOTE **  The hexadecimal values given in 4. and 7. above are those
for Epson printers, for which the Underline Mode ON command is: <ESC>-1,
and for OFF is: <ESC>-0.  If you have a printer with different ON and
OFF commands, the hexadecimal values will have to be changed
correspondingly.

The job is almost done, and you are now back at the A> or B>, or
wherever you started.  From now on, when writing a file use ^PY in the
way that you previously used ^PS, and in the printed version of what you
have written the expressions that you marked will have continuous
underlining below them.  At the same time, you can go on using ^PS just
as you do now whenever you want to produce the broken dash kind of
underlining.

There is just one more thing you have to remember when you are using
this method of underlining.  Dot matrix printers are very literal
creatures, and when they are in Underline Mode they underline
everything, including spaces between words, and also the blank space in
the left margin.  If you want "The Wind in the Willows" (the whole title
continuously underlined), "^PYThe Wind in the Willows^PY" will give it
to you.  If you want "The Wind in the Willows" (each word separately
underlined), you will have to write it as "^PYThe^PY ^PYWind^PY ^PYin^PY
^PYthe^PY ^PYWillows^PY".

And if, when you are using the first way, the book title happens to run
over from the end of one line on your screen to the beginning of the
next, in the printed version the blank space in the left margin of that
second line will get underlined too.  You can prevent that by putting in
a closing ^PY at the end of the first line and a new opening ^PY at the
beginning of the next.  But it is a nuisance to have to remember that on
each occasion, and there is a cleaner way that I have been using for a
long time, that I recommend.  It consists simply of telling WordStar
that you are not going to have any left margin at all, and then secretly
telling your printer to put it back again.

1. You remove the margin from WordStar by reducing the Page Offset to
zero with the dot command: .PO 0.  If it is worth your while, you could
change your default Page Offset to that; and then you wouldn't have to
think about it each time.

2. To get the printer to put the margin back again you have to run a
very short file in Basic before giving the command to print.  I call the
file LMARG.BAS; and this is all it consists of:

10 LPRINT CHR$(27)"l"CHR$(10)
20 SYSTEM

If you don't know what that means, it doesn't matter.  It tells the
printer to put in a left margin of 10 characters.  And if you don't know
how to write and save that to disk in Basic, get a friend who does know
to do it for you.

Make sure that you have MBASIC.COM and LMARG.BAS on the same disk as
your WordStar files.  Now, when you have finished writing your file in
WordStar and are ready to print it, first turn on the printer and then
from the Opening Menu choose:

"R Run a program" and enter: "mbasic lmarg  <CR>".  The Basic program
will run, set the margin on the printer and return you to the Opening
Screen where you give the command P and start printing as usual.

That may all sound very complicated.  But remember that you have to do
it only once.  Thereafter, whenever you want to print anything and have
the underlining (or some of it) continuous, all you have to do is: (i)
to insert the .PO 0 command at the beginning of your file.

  (ii) to enclose the expressions to be continuously underlined within a
^PY . . . .^PY command.

  (iii) when you are ready to print, to give those final R and P
commands.

If you are satisfied with the results, you can delete your old WordStar
file (OLDWS.COM).  If you are not satisfied delete the one you have been
playing around with (WS.COM), and rename OLDWS.COM as WS.COM.  You will
have lost nothing but some time and trouble.

Postscript.  To any of you who are using one of those new-fangled MS-DOS
Kaypros: the WINSTALL procedure for you is exactly the same as that I
have described for the CP/M version, except that the starting addresses
you will be given for RIBBON and RIBOFF are different (they are 793h and
798h).  All the steps you have to take are just as I have given them.

- Tony Woozley

.dec.com>@brl-adm.ARPA (01/07/87)

J. Lee (hounx!jong) offers another approach to the continuous underline query:

> Well, there is a better way [than the non-break space] to do this. You can
> run install program (wsinstall, was it? it's been a while since I used the
> WS) and go to the printer configuration menu.  There, you can set it up so
> that the WS command for underscore (whatever it is) issues the control
> string to put your printer in underline mode...

Sorry, but I don't think so.  WS does underscoring in one of two ways:

1.  By printing each character to be underscored, backspacing, and printing
    the underscore.  This is for printers that do an automatic linefeed on
    receipt of a carriage return.

2.  By printing a line of characters, issuing a <CR> without a <LF>, and then
    printing the desired underscores.  This is for printers that do *not* do
    an auto-linefeed, and it's much faster.  It's also less wear and tear on
    the printer - use it if you can.

The ^PS command is a toggle command that starts WS underscoring as I've 
described.  It does *not* issue a printer control sequence and therefore can't
be made to flick the printer into continuous-underscore mode.  Even if you
could do it, what would you do to get the printer *out* of that mode?  WS
turns off its underscoring by sensing a repeat of the ^PS command. 

It is still possible, and easy, to use two of the custom printer codes ^PQ, 
^PW, ^PE, and ^PR - run WINSTALL and select the custom printer installation 
menu item, and then select the optional user-defined codes option.  Set up one 
code to turn on underscoring and another to turn it off.  I can't do this 
because I've got every one of the WS print control commands used, even ^PY.

Or you can use the ANYCODE2 patch I described in an earlier posting - it 
allows you to insert ANY printer control sequence, even if you've got WS 
loaded up with all its options used.  I'm in the process now of sending a 
softcopy of ANYCODE2 and its documentation to Keith Petersen to be added to 
the SIMTEL20 archives.  ANYCODE2 is a little more difficult to set up, but it 
gives you incredible versatility, and it's easy to use once set up.

Cheers,
Dick Binder   (The Stainless Steel Rat)

DEC Enet:	ASD::BINDER
UUCP:		{ decvax, allegra, ucbvax... }!decwrl!asd.dec.com!binder
ARPA:		binder%asd.DEC@decwrl.ARPA