Discussion:
Trying to Print to LPT4 and Above????
(too old to reply)
Derek Ross
2004-09-15 15:16:13 UTC
Permalink
Hello Paul, did you have any answer on this? I am having exactly the SAME
problem. Can you please e-mail me the answer to
I can't check right now but I would have thought that once you have
issued the NET USE command to configure the LPT4: printer. The
following code would allow you to print to it.

LET P4 = FREEFILE
OPEN "LPT4:" FOR OUTPUT AS #P4
PRINT #P4, "Hello Printer"
CLOSE #P4

Cheers

Derek
Derek Ross
2004-09-16 06:08:06 UTC
Permalink
Post by Derek Ross
Hello Paul, did you have any answer on this? I am having exactly the SAME
problem. Can you please e-mail me the answer to
I can't check right now but I would have thought that once you have
issued the NET USE command to configure the LPT4: printer. The
following code would allow you to print to it.
LET P4 = FREEFILE
OPEN "LPT4:" FOR OUTPUT AS #P4
PRINT #P4, "Hello Printer"
CLOSE #P4
Unfortunately a quick test indicates that the above doesn't work with
QBASIC and so probably won't work with VBDOS. Something more
complicated such as the following will be required.

LET P4 = FREEFILE
OPEN "PRINTOUT.TXT" FOR OUTPUT AS #P4
PRINT #P4, "Hello Printer"
CLOSE #P4
SHELL ENVIRON$("COMSPEC") + " /C TYPE PRINTOUT.TXT >LPT4:"
KILL "PRINTOUT.TXT"

This prints to a temporary file first and then uses a DOS command to
send the file to the printer.

Cheers

Derek
a***@NOW.AT.arargh.com
2004-09-16 10:05:22 UTC
Permalink
Post by Derek Ross
Post by Derek Ross
Hello Paul, did you have any answer on this? I am having exactly the SAME
problem. Can you please e-mail me the answer to
I can't check right now but I would have thought that once you have
issued the NET USE command to configure the LPT4: printer. The
following code would allow you to print to it.
LET P4 = FREEFILE
OPEN "LPT4:" FOR OUTPUT AS #P4
PRINT #P4, "Hello Printer"
CLOSE #P4
Unfortunately a quick test indicates that the above doesn't work with
QBASIC and so probably won't work with VBDOS. Something more
complicated such as the following will be required.
Does it work without the ":"?

LPT1-3 names are hard coded in QBasic and VBDOS with the ":".
Names ending in a ":" must be known to the runtime.
"LPT4:" would not be known.
<snip>
--
Arargh409 at [drop the 'http://www.' from ->] http://www.arargh.com
BCET Basic Compiler Page: http://www.arargh.com/basic/index.html

To reply by email, remove the garbage from the reply address.
Derek Ross
2004-09-16 15:51:02 UTC
Permalink
Post by a***@NOW.AT.arargh.com
Post by Derek Ross
Post by Derek Ross
Hello Paul, did you have any answer on this? I am having exactly the SAME
problem. Can you please e-mail me the answer to
I can't check right now but I would have thought that once you have
issued the NET USE command to configure the LPT4: printer. The
following code would allow you to print to it.
LET P4 = FREEFILE
OPEN "LPT4:" FOR OUTPUT AS #P4
PRINT #P4, "Hello Printer"
CLOSE #P4
Unfortunately a quick test indicates that the above doesn't work with
QBASIC and so probably won't work with VBDOS. Something more
complicated such as the following will be required.
Does it work without the ":"?
LPT1-3 names are hard coded in QBasic and VBDOS with the ":".
Names ending in a ":" must be known to the runtime.
"LPT4:" would not be known.
Yes, I did try that. I got a different error (Path/Access) but still
an error which was why I suggested the intermediate file/SHELL method
instead.

Cheers

Derek
Jim Mack
2004-09-16 11:20:22 UTC
Permalink
Post by Derek Ross
LET P4 = FREEFILE
OPEN "PRINTOUT.TXT" FOR OUTPUT AS #P4
PRINT #P4, "Hello Printer"
CLOSE #P4
SHELL ENVIRON$("COMSPEC") + " /C TYPE PRINTOUT.TXT >LPT4:"
KILL "PRINTOUT.TXT"
This prints to a temporary file first and then uses a DOS command to
send the file to the printer.
Cheers
Derek
It's even simpler to:

P4 = FREEFILE
OPEN "LPT4" FOR OUTPUT AS #P4

' or better, "\dev\lpt4"

PRINT #P4, "Hello Printer"
CLOSE #P4

...and skip the file altogether. This assumes that there really is an
LPT4, but then, so does your example.
--
Jim
Derek Ross
2004-09-17 07:04:34 UTC
Permalink
Post by Derek Ross
Post by Derek Ross
LET P4 = FREEFILE
OPEN "PRINTOUT.TXT" FOR OUTPUT AS #P4
PRINT #P4, "Hello Printer"
CLOSE #P4
SHELL ENVIRON$("COMSPEC") + " /C TYPE PRINTOUT.TXT >LPT4:"
KILL "PRINTOUT.TXT"
This prints to a temporary file first and then uses a DOS command to
send the file to the printer.
Cheers
Derek
P4 = FREEFILE
OPEN "LPT4" FOR OUTPUT AS #P4
' or better, "\dev\lpt4"
PRINT #P4, "Hello Printer"
CLOSE #P4
...and skip the file altogether. This assumes that there really is an
LPT4, but then, so does your example.
I did try that before posting but since it produced an error for me, I
posted the more complicated solution with the file.

Cheers

Derek

Loading...