[comp.sys.ibm.pc.programmer] C program to download chars to printer, help needed

weeks@ssbell.IMD.Sterling.COM (John Weeks) (05/04/90)

In article <5883.263c08cb@uwovax.uwo.ca> chet@uwovax.uwo.ca writes:
>Am trying for the first time to download characters to my Star NX-1000
>printer, and it is not going very well. Can anyone send me an alternative
>(in C) or suggest what I am doing wrong?
>
>char
>draft[] = {27, 'x', 0},  /* selects draft quality */
>standard[] = {27, ':', 0, 0, 0},    /* copies standard chars from ROM to RAM */
                        ^  ^
You are sending binary zeros here, where you want to send "escape, colon,
character zero, character zero, null terminator (binary zero)".  The first
'0' in your initializer is the null terminator when you send the string.
what you want is:

 	draft[] = {27,':','0','0',0}
or
	draft[] = {27,':',48,48,0}
or many other variations on the theme.  The main point is that the control
strings for the printer are specified in terms of characters.  You can
represent the characters in a variety of ways: character literals (':'),
ascii codes (48 for '0', 27 for the escape character ... ).  If you are
using an editor that lets you insert control characters in the text, you
can use quoted strings ("->:00") (the escape shows as a single character
right arrow, as I recall, in the eight bit ascii set on a PC.)  Note
that when you use quoted strings the zeros are characters and the null
terminator is provided for you.

>engma[] = {27,'&',0,181,181,138,124,0,64,1,64,1,66,60,0,0,0}
       Here too:   ^                 ^                 ^ ^
>eth[] = {27, '&',0,182,182,10,160,4,74,160,18,12,0,0,0,0},
       Also here: ^                               ^ ^ ^
>car[] = {27, '&',  0, 60, 60,139,124,0,66,4,64,36,16,2,16,12,0},
       And here:    ^                 ^
>download[] = {27, '%', 1};	/* select draft download chars */

-- 

John Weeks                                    Phone:  (402) 291-8300
Sterling Software IMD            e-mail: uunet!ssbell!weeks
1404 Ft. Crook Rd. South         e-mail: weeks@ssbell.IMD.Sterling.COM