[comp.sys.amiga] Printer troubles

schwager@uiucdcsm.UUCP (09/16/87)

Here's an odd little problem I'm having:
I can't seem to get the ASCII "escape" character to my printer.
From BASIC, I do a:
	lprint chr$(27)+"W"+chr$(1)+"hello"
which is supposed to print the word "hello" double-width, but it
doesn't.  "hello" is simply printed in normal pica.  I've tried other
escape codes also, to no avail.  I can power my printer up in Hex mode.
Then the ASCII representation of every char sent to the printer is
supposed to print.  Instead of getting:

1B 57 01 68 65 6C 6C 6F

like I'm supposed to, I get:

01 68 65 6C 6C 6F

In other words, the escape char and the "W" evaporate.  Any ideas?
"Sure," you say, "don't use BASIC."  Well, I don't usually, but I'm
trying to enter a utility from a magazine, and I'd like for the program
to be able to set the width and other parameters on the printer.  
So, constructive ideas, anyone?  Many thanks....
-mike schwager
-- {ihnp4,convex,pur-ee}!uiucdcs!schwager   schwager%uiuc@csnet-relay.arpa
	University of Illinois, Dept. of Computer Science

stever@videovax.UUCP (09/17/87)

In article <7200009@uiucdcsm>, Mike Schwager( schwager@uiucdcsm.cs.uiuc.edu)
writes:

> Here's an odd little problem I'm having:
> I can't seem to get the ASCII "escape" character to my printer.
> From BASIC, I do a:
> 	lprint chr$(27)+"W"+chr$(1)+"hello"
> which is supposed to print the word "hello" double-width, but it
> doesn't.  "hello" is simply printed in normal pica.  I've tried other
> escape codes also, to no avail.  I can power my printer up in Hex mode.
> Then the ASCII representation of every char sent to the printer is
> supposed to print.  Instead of getting:
> 
> 1B 57 01 68 65 6C 6C 6F
> 
> like I'm supposed to, I get:
> 
> 01 68 65 6C 6C 6F
> 
> In other words, the escape char and the "W" evaporate.  Any ideas?

"lprint" does swallow escapes!  To avoid this, do

      OPEN "PAR:" FOR OUTPUT AS #1
        .
        .
        .
      PRINT #1,CHR$(27)+"W"+CHR$(1)+"hello"

(If your printer is on the serial port, open that instead of PAR:.)

This is a bit of a kludge, but it will work. . .

					Steve Rice

P.S. My manuals and my Amiga are at home, so I please excuse any errors
     in the command format!

-----------------------------------------------------------------------------
new: stever@videovax.tv.Tek.com
old: {decvax | hplabs | ihnp4 | uw-beaver | cae780}!tektronix!videovax!stever

daveb@cbmvax.UUCP (Dave Berezowski) (09/18/87)

In article <7200009@uiucdcsm> schwager@uiucdcsm.cs.uiuc.edu writes:
>
>Here's an odd little problem I'm having:
>I can't seem to get the ASCII "escape" character to my printer.
>From BASIC, I do a:
>	lprint chr$(27)+"W"+chr$(1)+"hello"
>which is supposed to print the word "hello" double-width, but it
>doesn't.  "hello" is simply printed in normal pica.  I've tried other
>escape codes also, to no avail.  I can power my printer up in Hex mode.
>Then the ASCII representation of every char sent to the printer is
>supposed to print.  Instead of getting:
>
>1B 57 01 68 65 6C 6C 6F
>
>like I'm supposed to, I get:
>
>01 68 65 6C 6C 6F
>
>In other words, the escape char and the "W" evaporate.  Any ideas?
>"Sure," you say, "don't use BASIC."  Well, I don't usually, but I'm
>trying to enter a utility from a magazine, and I'd like for the program
>to be able to set the width and other parameters on the printer.  
>So, constructive ideas, anyone?  Many thanks....
>-mike schwager
>-- {ihnp4,convex,pur-ee}!uiucdcs!schwager   schwager%uiuc@csnet-relay.arpa
>	University of Illinois, Dept. of Computer Science


	Sounds to me like you are sending the characters through the
printer device's filter.  ie. It is expecting Amiga standard escape
sequences which it translates to escape sequences for the particular
printer selected under preferences.  'ESC[6w' is the proper command
to turn on enlarged (double width) text.

	If you don't want to use the standard Amiga commands, then you'll
have to send the output directly through the parallel or serial port.
(depending on whether you have a parallel or serial printer).  Unfortunately,
I don't know how to do this in Amiga Basic.

	Regards, D.B.

guilford@csv.rpi.edu (Jim Guilford) (09/18/87)

In article <7200009@uiucdcsm> schwager@uiucdcsm.cs.uiuc.edu writes:
>
>Here's an odd little problem I'm having:
>I can't seem to get the ASCII "escape" character to my printer.
>From BASIC, I do a:
>	lprint chr$(27)+"W"+chr$(1)+"hello"
>which is supposed to print the word "hello" double-width, but it
>doesn't.  "hello" is simply printed in normal pica.  I've tried other
>escape codes also, to no avail.  I can power my printer up in Hex mode.
...
>In other words, the escape char and the "W" evaporate.  Any ideas?
...
>-mike schwager
>-- {ihnp4,convex,pur-ee}!uiucdcs!schwager   schwager%uiuc@csnet-relay.arpa
>	University of Illinois, Dept. of Computer Science

I'll try a stab at an idea. Note that I haven't used basic in quite a while,
so I will be taking things froma C, CLI perspective. This may be the cause of
what you are seeing, though. Are you aware that there are two devices that
talk to the printer? There is the par: device which is actually the
parrallel port. This goes directly to the printer (I am assuming that your
prointer is on the parrallel port). Then there is the prt: device which
filters the output before sending it to the printer. In order to handle
different printers in an independant way, the amiga has defined its own set
of printer escape sequences. These are similar but not identical to the ansi
sequences. Programs send these to the prt: device which then translates them
into the sequences needed by the printer as specified in preferences.

What I am trying to say is that if you looked up the sequence in your
printer manual and send it to the prt: device, it may not work. The esc-W
that you send may not match an amiga sequence and get eaten. You should
either use the amiga sequences (I think they are documented in the DOS
manual, but off hand I am not sure), or use the par: device (I needed to do
some hairy things with my printer and had to use par:). I am not sure how
you would do this in basic, but I would guess that you would open "par:" as
a file, and then print #x to it.

--Jim Guilford    (JimG)
guilford@csv.rpi.edu

kasper@su-russell.ARPA (Kasper Osterbye) (09/19/87)

In article <4580@videovax.Tek.COM> stever@videovax.Tek.COM (Steven E. Rice, P.E.) writes:
>In article <7200009@uiucdcsm>, Mike Schwager( schwager@uiucdcsm.cs.uiuc.edu)
>writes:
>
>> Here's an odd little problem I'm having:
>> I can't seem to get the ASCII "escape" character to my printer.
>> From BASIC, I do a:
>> [Rest deleted cause the mailer asked to do so, Kasper]
>"lprint" does swallow escapes!  To avoid this, do
>
>      OPEN "PAR:" FOR OUTPUT AS #1
>        . . .   
>      PRINT #1,CHR$(27)+"W"+CHR$(1)+"hello"
>
>(If your printer is on the serial port, open that instead of PAR:.)
>
>This is a bit of a kludge, but it will work. . .
>
>					Steve Rice

Sorry for deleting, but otherwise this would grow to much.

I had the same problem as Mike. And a huried to my amiga when
I came home after reading Steve's note. And it sure worked, I
was able to get italics and proportional spacing and god knows
what. BUT I was not able to get by danish or any other ALT-selected
charaters through anymore. Apparently the PRT: device is smart,
(it is I checked the output to the printer in hexcode like Mike did,
the ALT-selected characters were expanded into strings as long as
nine bytes long).

So do Steve, or any boddy else know how to send escapes to the PRT:
device?

kasper.

ARPA kasper@russell.stanapo).  Ce

foy@aero.ARPA (Richard Foy) (09/19/87)

In article <7200009@uiucdcsm> schwager@uiucdcsm.cs.uiuc.edu writes:
>
>Here's an odd little problem I'm having:
>I can't seem to get the ASCII "escape" character to my printer.
>From BASIC, I do a:
>	lprint chr$(27)+"W"+chr$(1)+"hello"
>-mike schwager
>-- {ihnp4,convex,pur-ee}!uiucdcs!schwager   schwager%uiuc@csnet-relay.arpa
>	University of Illinois, Dept. of Computer Science


I struggled with this problem for some time. The Amiga has standard char
sequences for all of its printer drivers. The Enhancer 1.2 update manual
describes these translations. I don't have it with me so I don't remember
what they are.

Richard Foy

bryce@hoser.berkeley.edu (Bryce Nesbitt) (09/19/87)

In article <7200009@uiucdcsm> schwager@uiucdcsm.cs.uiuc.edu writes:
>
>Here's an odd little problem I'm having:
> [I send an "escape" character to PRT: via BASIC, but the escape
> gets eaten!]
> [I use my printer's specific sequence]
> which is supposed to print the word "hello" double-width, but it
> doesn't.

The Amiga printer driver implements a standard set of commands.  It's
"double-width" command  gets translated into whatever your printer's
actual command is.  It is best to use this, since your program will
then work on all printers that have Amiga drivers and double-width
capability.

The commands are documented in the Amiga Enhancer Software manual
(The V1.2 Kickstart upgrade).  Page 22.  Or Appendix D of the
introduction to the Amiga 500.  The code you need to send to use
double-width is escape then "[6w"

If you absolutly must send a direct command you will need to use
the direct access PAR: or SER: devices.  I thought that there was
a way to convince the PRT: device to pass some direct characters
through... seems that you can't do it.  (without a program).

It's not very clean to do the direct access.  Perhaps a future PRT:
will have some "last resort" command that will then let anything
pass unmolested until a termination sequence.

 
|\ /|  . Ack! (NAK, ENQ, SYN)
{o O} . 
 (") 	bryce@hoser.berkeley.EDU -or- ucbvax!hoser!bryce
  U	How can you go back if you have not yet gone forth?

carolyn@cbmvax.UUCP (Carolyn Scheppner CATS) (09/22/87)

In article <353@su-russell.ARPA> kasper@su-russell.UUCP (Kasper Osterbye) writes:
>In article <4580@videovax.Tek.COM> stever@videovax.Tek.COM (Steven E. Rice, P.E.) writes:
>>In article <7200009@uiucdcsm>, Mike Schwager( schwager@uiucdcsm.cs.uiuc.edu)
>>writes:
>>
>>> Here's an odd little problem I'm having:
>>> I can't seem to get the ASCII "escape" character to my printer.
>>>[]
>
>I had the same problem as Mike. And a huried to my amiga when
>I came home after reading Steve's note. And it sure worked, I
>was able to get italics and proportional spacing and god knows
>what. BUT I was not able to get by danish or any other ALT-selected
>charaters through anymore.
>[]


1. All printer commands such as Italics, Bold, etc. should be sent
   to the printer device as standard ISO sequences which will be
   translated by the installed printer driver to the correct
   printer-specific sequence for the printer being used. (As long
   as that printer and driver support what you asked for).  The ISO
   printer sequences are listed in the Enhancer, A500, and A2000
   manuals.

   AmigaBasic 1.1 LPRINT used to eat initial escape characters.  The
   workaround was to instead OPEN "PRT:" FOR OUTPUT AS #n, then
   PRINT#n "whatever".  I just checked 1.2 AmigaBasic's LPRINT and 
   it works properly, and does not eat initial escape sequences.

2. Under 1.2, the correct way to generate foreign accented characters
   is through the use of DeadKeys.  The 1.2 Enhancer manual shows
   the DeadKeys defined on the US and international A1000 keyboards.
   In the manual diagrams, the DeadKeys are shaded gray and each have
   an accent key shown on their keycap.  To type any valid accented
   letter which is part of the international ASCII set, you press ALT
   AND the shaded key with the desired accent, then type the letter
   that you want accented.  This allows you to type foreign characters
   in most programs.  It works in string requesters, in CLI, in Ed,
   and in AmigaBasic 1.2.  (It does not work in programs which use
   unprocessed RAW key input).

   So, on a US keyboard for instance,

      ALT/f a     is an 'a' with a ' accent.
      ALT/g a     is an 'a' with a ` accent
      ALT/h e     is an 'e' with a ^ accent
      ALT/j n     is an 'n' with a ~ accent
      ALT/k u     is a 'u' with an umlaut (..) accent


   So, If you want to print foreign characters with AmigaBasic 1.2, you
just type them in your strings.  No escapes required.  Using the DeadKeys,
just put those characters in your normal quoted string and LPRINT the
string.


----------------------------------------------------------------------
REM - HERE IS AN AMIGABASIC EXAMPLE OF 1. and 2. ABOVE:

REM - Escape Test
REM - Remember, If your printer/driver can't do Bold or Italics, it won't.

Bold$   = CHR$(27) + "[1m"
Italic$ = CHR$(27) + "[3m"
Normal$ = CHR$(27) + "[0m"

LPRINT Bold$;"Bold Test";Normal$
LPRINT Italics$;"Italics Test";Normal$
LPRINT "DeadKey Test: (accented letters)"

                            \
                             \
                  I can't show the accented characters in this message.
                  Just type them in as explained above.

-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Carolyn Scheppner -- CATS   >>Commodore Amiga Technical Support<<
                     UUCP  ...{allegra,ihnp4,rutgers}!cbmvax!carolyn 
                     PHONE 215-431-9180
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=