Posts: 17
Threads: 5
Joined: Jul 2022
Reputation:
0
Thanks for all the input.
Those control codes I gave as examples were, I believe, PCL3 from the time I had my HPIII workhorse. They have continued to work for 25+ years on almost every laser printer I have tried, HP, Brother Lexmark, Canon, Kyocera, etc. even with many "Windows only" printers so I don't think compatibility would be an issue.
In QB64, it appears Lprint can't send chr$(27) to the printer. I have tried printing to a file and then sending the file to the printer and that has worked fine, but, since I have such a large QBasic system (as I said, thousands of Lprint lines scattered throughout) changing all my programs to go first to a file would be very unwieldy.
Hope I can find a different workaround.
Arnold
I
Posts: 2,177
Threads: 222
Joined: Apr 2022
Reputation:
104
08-04-2022, 02:34 AM
(This post was last modified: 08-04-2022, 02:34 AM by Pete.)
I very much doubt this would work. It is a statement that is on by default, but can be turned off, as shown below, and when off it allows the characters to be printed to the screen, like chr$(13), chr$(7), etc. So logically this should not make a difference in printing, as you would think it would want to be default (on) when sending chr$(27) as a printer escape code, but as a last resort, it might be worth one try. It just needs to be placed at the top of the program.
_CONTROLCHR OFF
Posts: 17
Threads: 5
Joined: Jul 2022
Reputation:
0
(08-04-2022, 02:34 AM)Pete Wrote: I very much doubt this would work. It is a statement that is on by default, but can be turned off, as shown below, and when off it allows the characters to be printed to the screen, like chr$(13), chr$(7), etc. So logically this should not make a difference in printing, as you would think it would want to be default (on) when sending chr$(27) as a printer escape code, but as a last resort, it might be worth one try. It just needs to be placed at the top of the program.
_CONTROLCHR OFF
You were right. I tried it and no luck.
Posts: 17
Threads: 5
Joined: Jul 2022
Reputation:
0
Hi Guys,
I figured out a (kludgy) workaround. I implemented it in one of my programs and it seems to work (until it doesn't.)
Before I modify all my other programs, I wanted to get your input on possible pitfalls.
At the beginning of the program I open a file, "printer.prn" for Output as file number ff%.
I changed ALL my Lprints to Print #ff%, (something I tried very hard to avoid.)
Every time I issue a page feed, Print #ff%, chr$(12), I call this sub:
Sub PrintTheFile
printfile$ = "printer.prn"
Close ff%
Shell _Hide "copy " + printfile$ + " prn"
Open "O", ff%, printfile$:
End Sub
I probably could have used PRINT instead of COPY. One of the downsides here is that using SHELL copy (or PRINT) sends it out LPT1 so I have to make sure LPT1 is redirected properly.
I found SUBing after each page feed gave me much more control then waiting until the entire job was in the file.
I close the file and reopen it to make sure what I already sent to the printer does not get reprinted.
Any comments would be appreciated.
A
Posts: 7
Threads: 1
Joined: May 2022
Reputation:
0
I too really miss printer control codes. I wish to drive a Laserjet using HPGL. I call HPGL output with a PCL escape code to eg draw a right angled triangle:
'****** test of hpgl
LPrint Chr$(27); "E"; 'printer reset
LPrint Chr$(27); "&l1O" 'landscape 0O for portrait
LPrint Chr$(27); "%0B"; 'enter hpgl using previous hpgl cursor posit
LPrint "IN"; 'initialise
LPrint "SC0,40,0,40,2;"; 'working in millimetres
LPrint "SP1PA10,10;" 'select pen1 move to 10,10
LPrint "PD;" 'pen down &
LPrint "PA50,10;"; 'draw (50,10)
LPrint "PA10,20;"; ' (10,20)
LPrint "PA10,10;"; ' (10,10)
'LPRINT CHR$(27); "%0A"; 'enter pcl mode
LPrint Chr$(27); "E"; 'reset to end & print
It is not clear from this discussion if it is not possible to add control codes to QB64PE for some technical reason (but apparently CHR$(27) works?) or that it is possible but just hasn't been done?
If the latter can I ask that this is scheduled for a subsequent release please?
Posts: 734
Threads: 30
Joined: Apr 2022
Reputation:
43
Just open a TCP/IP connection to the printer on port 9100 and send raw printer commands.
Tread on those who tread on you
Posts: 7
Threads: 1
Joined: May 2022
Reputation:
0
Thanks for this, but as a computer novice 'just' seems rather daunting,I have no idea how to do it; in any case the whole point of QB64PE is that it replicates QB4.5.
One of the contributors above says (CHR$12) still works to eject a page - if one escape code works then why can't the others?
I repeat my question - is this because it is technically impossible or because it just hasn't been done?
Posts: 734
Threads: 30
Joined: Apr 2022
Reputation:
43
04-30-2024, 11:10 AM
(This post was last modified: 04-30-2024, 11:32 AM by SpriggsySpriggs.)
So a computer novice is sending raw escape sequences to printers? I'm only changing the method by which they arrive at the printer.
Also, straight from the Wiki page for LPRINT:
"Note: Printer escape codes starting with CHR$(27) will not work with LPRINT and may produce text printing errors."
It looks like the page that Kevin and I worked on is no longer on the Wiki (PE and "official") about how to communicate with a printer via TCP/IP and send pages for print. Oh well.
But I did find the post on the old forum. Code I helped Kevin make: https://qb64forum.alephc.xyz/index.php?t...#msg129378
Tweak it as you see fit. Printing via TCP/IP has worked for me quite often. I may not have been the one who discovered doing it this way (because I have no idea if I was) but I was the one making good use of it for a long, long time. Used it extensively at a previous programming job.
Tread on those who tread on you
Posts: 7
Threads: 1
Joined: May 2022
Reputation:
0
05-04-2024, 10:30 PM
(This post was last modified: 05-04-2024, 10:32 PM by Wolstan Dixie.)
QB4.5 made it easy from within the programme and PCL and HPGL are hardly complex; Arnoldhf above had thousands of LPRINT lines using Escape codes.
With the greatest respect you still haven't answered my question - is it not implemented because it is technically impossible or because it just hasn't been done?
Posts: 17
Threads: 5
Joined: Jul 2022
Reputation:
0
(05-04-2024, 10:30 PM)Wolstan Dixie Wrote: QB4.5 made it easy from within the programme and PCL and HPGL are hardly complex; Arnoldhf above had thousands of LPRINT lines using Escape codes.
With the greatest respect you still haven't answered my question - is it not implemented because it is technically impossible or because it just hasn't been done? Whether it's the QB64 team or Microsoft, etc. we are all the mercy of the platform developers as to what can and perhaps can't be done.
I was able to easily, albeit reluctantly , change all my Lprint to Print #ff lines with a program wide search and replace ALL. Similar with Lprint chr$(12). One issue I would have the TCP/IP route suggested is that it would be embedded in the code and would require changing the code itself if the printer IP changes. At least with the way I finally did it, all I had to do was, before running the program, redirect LPT1 to whatever printer I wanted using a DOS command e.g NET USE LPT1: \\computername\printername /persistent.
|