Posts: 17
Threads: 5
Joined: Jul 2022
Reputation:
0
I found this under LPRINT:
- Note: Printer escape codes starting with CHR$(27) will not work with LPRINT and may produce text printing errors.
In my QBasic program I made extensive use of ESC for font changes, orientation changes, box shading (many times I did these on the same page as needed), etc.,
In QB64, chr$(27) sent to printer only results in a left arrow character.
these are just some:
LPrint Chr$(27); "&l1E"; 'move to top of page
LPrint Chr$(27); "&l64F"; 'set text length to 64 lines
10 courier10$ = Chr$(27) + "(11U" + Chr$(27) + "(s0p10.00h10.0v0s0b3T" ' courier 10 pitch
LPrint courier10$;
12 courier12$ = Chr$(27) + "(11U" + Chr$(27) + "(s0p12.00h10.0v0s0b3T"
LPrint courier12$;
17 courier17$ = Chr$(27) + "(11U" + Chr$(27) + "(s0p16.67h8.5v0s0b0T"
LPrint courier17$;
110 courierbold10$ = Chr$(27) + "(11U" + Chr$(27) + "(s0p10.00h10.0v0s3b3T"
111 LPrint courierbold10$;
210 courierbold12$ = Chr$(27) + "(11U" + Chr$(27) + "(s0p12.00h10.0v0s3b3T"
211 LPrint courierbold12$;
Any way I can send "printer" command codes like these to the printer in QB64 or accomplish the same results in another fashion?
Thanks,
Arnold
Posts: 276
Threads: 14
Joined: Apr 2022
Reputation:
27
I'm not experienced in the printer control codes as I never did any of that sort of stuff back in the QBasic days. With QB64 I predefine an appropriate size image, then use _PRINTIMAGE to send it to the printer once I've put what I want on it.
I defined a _NEWIMAGE(640, 900, 32) as being a good size and aspect ratio for an 8 1/2 x 11 page of text in the default font. It gave me 80 columns by 56 rows on the page. Then positioned my text with LOCATE & PRINT. It's a simple matter to do _PUTIMAGE stuff, or other graphics commands on the image the same way. I believe that _PRINTIMAGE is scaled to fit the page so if you define a different aspect ratio it will stretch things in unnatural ways.
If you go that route just remember that you have to set background colors for plain black text on white background in the images, or you'll end up with a soggy black sheet of paper.
DO: LOOP: DO: LOOP
sha_na_na_na_na_na_na_na_na_na:
Posts: 17
Threads: 5
Joined: Jul 2022
Reputation:
0
(08-03-2022, 09:54 PM)OldMoses Wrote: I'm not experienced in the printer control codes as I never did any of that sort of stuff back in the QBasic days. With QB64 I predefine an appropriate size image, then use _PRINTIMAGE to send it to the printer once I've put what I want on it.
I defined a _NEWIMAGE(640, 900, 32) as being a good size and aspect ratio for an 8 1/2 x 11 page of text in the default font. It gave me 80 columns by 56 rows on the page. Then positioned my text with LOCATE & PRINT. It's a simple matter to do _PUTIMAGE stuff, or other graphics commands on the image the same way. I believe that _PRINTIMAGE is scaled to fit the page so if you define a different aspect ratio it will stretch things in unnatural ways.
If you go that route just remember that you have to set background colors for plain black text on white background in the images, or you'll end up with a soggy black sheet of paper.
Thanks for your reply. If _PRINTIMAGE involves setting up a "screen" that then gets sent to the printer, I don't think that would work. Some of the print output I use requires different fonts with changes in BOLD, Italic, grey shading, boxes, 132 columns of printed text, even a change in text orientation from portrait to landscape all on the same printed page.
I was able to accomplish that using LPRINT with the appropriate printer control codes.
A
Posts: 2,177
Threads: 222
Joined: Apr 2022
Reputation:
104
08-03-2022, 10:53 PM
(This post was last modified: 08-04-2022, 03:49 PM by Pete.
Edit Reason: Swap _PRINTIMAGE for _PUTIMAGE.
)
I miss not having those printer escape codes, too. I used theme a lot to adjust the printer page for forms. You could move half spaces, move back, it was great!
As far as changing fonts, either _PRINTIMAGE as described, which is a lot of work, or slaving out your program to Wordpad, if you are on Windows. I just use an .rtf template that I create, take my program data and merge it into that template as a temp file, and then SHELL to Wordpad to print that file. Using .rtf format, you can chose and changes fonts, font size, margins, etc.
You can simply write something the way you want it to look in Wordpad, save it, and then open it in Notepad, which will show you the .rtf formatting. That's a quick and dirty way to make a template.
Then just SHELL _dontwait "START /min /p wordpad myfile.rtf"
Where myfile.rtf is the .rtf file you made and want to print, START /min starts wordpad in the task bar, and /p prints the doc.
Pete
Shoot first and shoot people who ask questions, later.
Posts: 17
Threads: 5
Joined: Jul 2022
Reputation:
0
(08-03-2022, 10:53 PM)Pete Wrote: I miss not having those printer escape codes, too. I used theme a lot to adjust the printer page for forms. You could move half spaces, move back, it was great!
As far as changing fonts, either _PUTIMAGE as described, which is a lot of work, or slaving out your program to Wordpad, if you are on Windows. I just use an .rtf template that I create, take my program data and merge it into that template as a temp file, and then SHELL to Wordpad to print that file. Using .rtf format, you can chose and changes fonts, font size, margins, etc.
You can simply write something the way you want it to look in Wordpad, save it, and then open it in Notepad, which will show you the .rtf formatting. That's a quick and dirty way to make a template.
Then just SHELL _dontwait "START /min /p wordpad myfile.rtf"
Where myfile.rtf is the .rtf file you made and want to print, START /min starts wordpad in the task bar, and /p prints the doc.
Pete
I will see if that is a feasible option. The QBasic modules I am converting probably comprise over 100,000 lines of code with thousands of Lprints. Just to be sure are you saying the Wordpad file will contain the control codes being sent to the printer?
A
Posts: 2,697
Threads: 327
Joined: Apr 2022
Reputation:
217
Control codes all vary by make and model of printer. You'll need to look up what works for your specific printer and see how to implement it.
https://help.brother-usa.com/app/answers...See%20More.
https://microsale.zendesk.com/hc/en-us/a...cape-Codes
https://help.ricohsoftware.com/swinfocen...t.ditamap/$/iprrl_pptpec
https://www.pclviewer.com/resources/reference/
Just a few ofthe different syntaxes out there for various printer models and software.
Posts: 2,177
Threads: 222
Joined: Apr 2022
Reputation:
104
(08-03-2022, 11:18 PM)arnoldhf Wrote: (08-03-2022, 10:53 PM)Pete Wrote: I miss not having those printer escape codes, too. I used theme a lot to adjust the printer page for forms. You could move half spaces, move back, it was great!
As far as changing fonts, either _PUTIMAGE as described, which is a lot of work, or slaving out your program to Wordpad, if you are on Windows. I just use an .rtf template that I create, take my program data and merge it into that template as a temp file, and then SHELL to Wordpad to print that file. Using .rtf format, you can chose and changes fonts, font size, margins, etc.
You can simply write something the way you want it to look in Wordpad, save it, and then open it in Notepad, which will show you the .rtf formatting. That's a quick and dirty way to make a template.
Then just SHELL _dontwait "START /min /p wordpad myfile.rtf"
Where myfile.rtf is the .rtf file you made and want to print, START /min starts wordpad in the task bar, and /p prints the doc.
Pete
I will see if that is a feasible option. The QBasic modules I am converting probably comprise over 100,000 lines of code with thousands of Lprints. Just to be sure are you saying the Wordpad file will contain the control codes being sent to the printer?
A
>Just to be sure are you saying the Wordpad file will contain the control codes being sent to the printer?
No. .rtf formatting in wordpad controls the printer output. You cannot use the escape codes from your program.
Example:
{\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1033{\fonttbl{\f0\fnil\fcharset0 Calibri;}{\f1\fnil\fcharset0 Arial Black;}}
{\*\generator Riched20 10.0.19041}\viewkind4\uc1
\pard\sa200\sl276\slmult1\f0\fs22\lang9 Test line in Calibri 11 pt font.\par
\b\f1\fs36 Test line in Arial Black in 18pt font.\b0\f0\fs22\par
}
Pete
Posts: 2,177
Threads: 222
Joined: Apr 2022
Reputation:
104
@SMcNeill
Does our Wiki need an update?
Note: Printer escape codes starting with CHR$(27) will not work with LPRINT and may produce text printing errors.
I thought at some point the ability to use all of the escape codes that worked in QBasic was lost. I think CHR$(12) still ejects the page from the printer, but I thought I tried other codes, several years ago, and they no longer worked. So at some point did subsequent versions of QB64 support escape codes that worked in QBasic? I haven't printed anything with QB64 for a very long time.
Pete
Shoot first and shoot people who ask questions, later.
Posts: 2,697
Threads: 327
Joined: Apr 2022
Reputation:
217
08-04-2022, 12:21 AM
(This post was last modified: 08-04-2022, 12:36 AM by admin.)
@Pete escape codes are said not to work anymore, as the old QBASIC ones were basically codes for DOS systems (much like PEEK and POKE addresses). Those old codes simply don't match modern systems.
That said, most printer manufacturers have distinct codes to control things (and many are customizable). All QB64 basically does is send a steam of information to the printer, and then the printer deals with it, according to it's own software. Your printer might want control codes to be formated as "/x1b/x0d/x0a" for a CRLF sequence. Then again, it might be "/027/013/010" or CHR$27) + CHR$(13) + CHR$(10) or even something else. Every printer I've experimented with over the years was different.
Instead of banging my head against a wall and trying to sort out something which isn't multi-system compatible, I've found it just easier to use _PRINTIMAGE. Format and preview what I want on the screen, then simply print the screen. Works no matter where I go, and I don't have to rewrite my code every few years when I buy a new printer (which seems cheaper than buying the ink refills for one anymore!).
Mt HP printer, for instance, works with these PCL3 codes: https://www.pclviewer.com/resources/reference/
Posts: 2,177
Threads: 222
Joined: Apr 2022
Reputation:
104
I have one of those smart printers. I took a picture of my junk once, and sent it to the printer. It started to ask me if I wanted to select landscape... and then said, never mind. I guess I should have said I have a smart ASCII printer.
Thanks for the reply/update
Pete
|