Printing

Please use this Board for QBasic related requests ( file research, programming, etc.)

Moderators:Administrator, Global Moderator

Post Reply
Leon
Printing

Post by Leon » Mon Sep 12, 2005 4:39 pm

I have an old Qbasic program that prints out directly to print port using
LPRINT command. Program works fine on one of the Windows XP Professinal systems, but not on others. All operating systems are the same. There are different type of printers, but all of them are older versions and I don't see why this happens. If anybody knows first which port LPRINT addresses (is it LPT1), and if there are switches I need to print there. Program has more than 4000 lines and I would like to avoid changing it by opening and writting to file if possible.

Thank you for any input.

buff1

Post by buff1 » Mon Sep 12, 2005 6:57 pm

Normally yes, Lprint goes to LPT1 (unless redirected like to com1 for
serial printers). You might check to see if it's printing data raw in the
switches.

If it's connected to a USB port you'll have to do something else.
If you have a network, you can still use it probably if you use a net use
command (though I don't know where to put it) -- it's basically a redirection command for the network.

If it's connected to LPT2 or LPT3 then you can easily access it by using
a 'file' type open instead of lprint.

open "LPTn:" for output as #16
for example where n=1, or 2, or 3.
then print to the # you open it with (in the example 16)
print #16, "This text should print on the printer"

Another alternative is to print to a file (like above open only a file name
like 'report.txt' for example) then use a windows program print the file
to the printer.

Ralph
QBasic God
Posts:134
Joined:Sat Nov 06, 2004 2:27 am
Location:Katy, Texas

Post by Ralph » Tue Sep 13, 2005 4:17 am

In addition to Buff1's good information, let me state my results:

Using QuickBASIC 4.5 win Windows XP Home Edition & Service Pack 2, a simple LPRINT does NOT make my HP LaserJet 4L, connected to LPT1, print out! I can see that the printer has received some kind of communication, as its lights blink on and off, but, the sheet does not print, nor does the sheet go through the printer. It must see 60 lines before it will print the first page, and, for each successive page, it must see 60 more lines.

However, a Forced Feed can be done, and the printer will print whatever it has received. For example, try the following programs:

'Program1 prints 1 page with 1 on line 1, 2 on line 2,...,and 60 on line 60.
FOR I =1 TO 60: LPRINT I: NEXT I

'Program2 prints nothing, unless one quits QuickBASIC, which will produce an automatic Form Feed.
FOR I = 1 TO 59: LPRINT I: NEXT I

'Program3 prints a page with 1, 2, 3,...44 on the first 44 lines.
FOR I = 1 TO 44: LPRINT I: NEXT I: LPRINT CHR$(12)

'Program4 will print a page with its lines containing 1, 2, 3,...,60 on them, and one more page, with only 61 on it.
FOR I = 1 TO 61: LPRINT: NEXT I: LPRINT CHR$(12)

'Program5 prints out two pages, each with 1, 2,...60 and the other with 61, 62,...120, and a third page, with 121, 122,...130 on it.
FOR I = 1 TO 130: LPRINT I: NEXT I: LPRINT CHR$(12)
Ralph. Running QuickBASIC Version 4.5, Windows XP Home Edition, Version 2002, Service Pack 2, and HP LaserJet 4L printer.

leon

Thanks

Post by leon » Wed Sep 14, 2005 6:46 pm

Thank you for all your help. I have resolved to write to a file instead of redirecting output. Since I've not programmed for a while it took some time, but now I have full control of output. Thanks again everyone. :)

For a reference there is an interesting web site for program very similar to Qbasic it is called JustBasic and it has very flexible GUI front end.
The software is free. Making EXE files is a little complicated but possible.
You may give it a try all.
:arrow:
Check website for more reference: http://www.justbasic.com

Post Reply