Printer escape sequences in SE table
Posted in 1999
Topics: General Discussion
I would like to set up a table that contains the escape sequences for compressed printer, etc for different printers. When I do this and select an escape sequence from the table and attempt to print using it I get the literal string, i.e. \\033&k2s (which is exactly what is in the table - the column is defined as a char). If I assign the string to a char variable in the program i.e., LET xstr = "\\033&k2S" and then print using this variable ( PRINT xstr CLIPPED, "THIS IS COMPRESSED") then the text string is printed in compressed format. I also tried setting the value in the column to \\\\033&k2S (attempting to escape the escape character) but this didnot work either. I know I've seen this done where it works, and believe that several years ago I did this. But for the life of me I cannot recall how. Anyone have any ideas and/or suggestions. Thanks in advance. Scott G. Gallup Information Services Manager Belle Tire Distributors Allen Park MI Scott_Gallup@msn.com
I think the safest way around this is to avoid storing non-printing characters in the database, but instead use "PRINT ASCII 27" in front of the statement to send the escape character. Your example would be: LET xstr = "&k2S" PRINT ASCII 27, xstr CLIPPED, "THIS IS COMPRESSED" The ASCII values for non-printing characters can be stored in the database as well, so you could select on "ESCAPE" or something to get the value. So the above could be: LET intVal = 27 LET xstr = "&k2S" PRINT ASCII intVal, xstr CLIPPED, "THIS IS COMPRESSED" Don't forget to end the mode with another ASCII 27, and use semi-colons to avoid adding line-feeds you don't want: PRINT ASCII 27, recLandScape; PRINT .... PRINT ASCII 27, recEndLandScape; Scott_Gallup wrote in message ... >I would like to set up a table that contains the escape sequences for >compressed printer, etc for different printers. When I do this and select an >escape sequence from the table and attempt to print using it I get the >literal string, i.e. \\033&k2s (which is exactly what is in the table - the >column is defined as a char). > >If I assign the string to a char variable in the program i.e., LET xstr = >"\\033&k2S" and then print using this variable ( PRINT xstr CLIPPED, "THIS IS >COMPRESSED") then the text string is printed in compressed format. > >I also tried setting the value in the column to \\\\033&k2S (attempting to >escape the escape character) but this didnot work either. > >I know I've seen this done where it works, and believe that several years >ago I did this. But for the life of me I cannot recall how. Anyone have any >ideas and/or suggestions. > >Thanks in advance. > >Scott G. Gallup >Information Services Manager >Belle Tire Distributors >Allen Park MI >Scott_Gallup@msn.com > >
Scott_Gallup wrote: > > I would like to set up a table that contains the escape sequences for > compressed printer, etc for different printers. When I do this and select an > escape sequence from the table and attempt to print using it I get the > literal string, i.e. \\033&k2s (which is exactly what is in the table - the > column is defined as a char). > > If I assign the string to a char variable in the program i.e., LET xstr = > "\\033&k2S" and then print using this variable ( PRINT xstr CLIPPED, "THIS IS > COMPRESSED") then the text string is printed in compressed format. > > I also tried setting the value in the column to \\\\033&k2S (attempting to > escape the escape character) but this didnot work either. > > I know I've seen this done where it works, and believe that several years > ago I did this. But for the life of me I cannot recall how. Anyone have any > ideas and/or suggestions. > > Thanks in advance. > > Scott G. Gallup > Information Services Manager > Belle Tire Distributors > Allen Park MI > Scott_Gallup@msn.com Hmm. I suspect C is getting in the way. If you use a literal in a 4GL compiled or an ESQL/C program like "\\023" the C compiler will interpret the escape sequence, hence your success in using a literal. If you try to enter the codes into a table though some form program, you will suffer from whatever the form program allows you to type. Probably the best way to do it is to maintain the printer codes in a text file you can edit with something that genuinely allows 8-bit editing and for which you understand the input and display escape sequences. vi would do. Then use that file to LOAD the database table, having first deleted any rows you intend to replace. To repeat - the problem is caused by one or more of the layers of software you are using. If you can identify the layer you are half-way to solving the problem. Good luck! -- Peter Lancashire Information Systems Specialist, Bayer plc Eastern Way, Bury St Edmunds, Suffolk, IP32 7AH, UK Tel: +44-1635-562258, Fax: +44-1635-562281 -- If all else fails, read the instructions and the release notes. Join Infuse, the UK Informix User Group at http://www.infuse.org.uk/
Here is my two penn'eth worth ...
One day you may need another printer type, so today is the day to
write a driver.
Table printer (
printer_type char (10), # epson, canon, HP
effect char (10), # bold, norm, underline, font etc.
code smallint, # decimal value for individual parts of
esc sequences
sort_nr smallint # to get it in the right order !
)
to get bold:
SELECT code, sort_nr
FROM printer
WHERE printer_type = "CANON" AND
effect = "bold"
ORDER BY sort_nr
pack this into an array (or charwise into a string with FOREACH)
FOR i = 1 TO <<length array>>
PRINT ASCII (array[i])
END FOR
> Don't forget to end the mode with another ASCII 27, and use semi-colons to
> avoid adding line-feeds you don't want:
>
Good thinking ...
You can pack this sort of stuff into a nice subroutine and PRESTO
Robert is your mothers uncle
Have fun
Nick Lefel, Hamburg