Page 1 of 2
Printing To a Network/Shared Printer From QB45 W/ XP PRO SP3
Posted: Sat Jul 24, 2010 11:17 pm
by paydata
I have just acquired a new computer with Windows XP PRO SP3. I have many Basic programs written in QB45 that I have been using since 1998. I would like to run them in source coding on my XP. I have transferred all the programs and files. I can access QB45 and start the programs, but I do not seem to be able to print to any of my networked printers (LPT1, LPT2, LPT3) which are all controlled from one computer. How do I get around this problem?
Network Printing
Posted: Sun Jul 25, 2010 4:26 pm
by I Daniel
My pennies worth
The QB4.5 manual says:
Qoute LPRINT. LPRINT USING xxx:
Prints data on the printer LPT1: unquote
This indicates that LPRINT only accesses the local printer port for LPT1. Since you are not printing to that port I doubt if u can print to a network printer.
I did a quick one line qb prog and then added a network printer to my computer to use the HP connected to my LAN but it was no go to print from QB4.5.
The only work-around I can see is to print to a file, open it with Wordpad and then print it on a network printer.
ie replace your LPRINT with a Print#,. ie : Open "Whatever.txt" for output as #5: Print#5,xxx: close #5
This of course is a terrible shlep.
U could open the COMn as a file but I doubt it that u are using the Com port (RS323) for you network.
BUT there are more brains out there so maybe someone may have written a quicklibrary to give access to a LAN.
Posted: Sun Jul 25, 2010 5:22 pm
by paydata
Hi Daniel,
Thanks for your response.
I am not using LPRINT, but assigning LPTx to a file. ie.
---------------------------------------------------------------------------
DEV$ = "LPT3"
CLOSE #6: OPEN DEV$ FOR OUTPUT AS #6
PRINT #6, "HELLO LPT3"
PRINT #6, CHR$(27); "&l0H": ' eject page (ESC &l0H)
PRINT #6, CHR$(27); "E"; : ' reset the printer (ESC E)
END
---------------------------------------------------------------------------
Does not work.
printing to a LAN printer
Posted: Sun Jul 25, 2010 8:24 pm
by I Daniel
I see our code is basically the same except that I suggested opening a file.
U r opening the printer as a file which is the same as LPRINT. Have you tried LPT1 iso Lpt3? (Since QB apparently only sees the local LPT1 printer port)
Sorry I cannot be of more assistance. But I will keep scratching around as there are a number of qbasic and other basic sites and my itch for info just wont stop itching.
Happy hunting.
Posted: Mon Jul 26, 2010 2:30 am
by buff1
If you have a network printer that is not on the local xp computer you should be able to use the NET USE command to redirect it to LPT1,2 or 3.
For some reason, it seems you cannot redirect a network printer that is on your local computer which I've tried to do. But as long as it is physically on another computer on the network, it should work fine. see help for net use command
Use LPTn where n =1,2, or 3 and is NOT being used.
Posted: Mon Jul 26, 2010 5:55 pm
by I Daniel
Hi Buff1
I never had this problem because I printed to my local printer And therefore did not realize that u were actually referring to the operating systems Printer and Fax setup troubleshooter and not a BASIC command from Powerbasic.
I found this under Windows Help and Support Centre when trying to print to a shared printer from QB4.5 when it came back with a print error. (Although REDIR.EXE should have done it automatically.)
Are you trying to print to a shared printer?
If you are printing to a network computer, you might need to redirect the port to your shared printer.
There are two methods you can use to redirect the port:
Establish a permanent connection using the Net.exe command
Click Start, point to All Programs, point to Accessories, and then click Command Prompt.
At the command prompt, type
net use lptx: \\printserver\sharename /persistent:yes where x is the number of the LPT port that you are using (usually 1 or 2), printserver is the name of your print server, and sharename is the name of the printer share.
To disconnect a persistent LPT connection, type the following at a command prompt:
net use lptx /delete
Print only the file you are working on to a shared printer
To print your file to a shared printer
Click Start, point to All Programs, point to Accessories, and then click Command Prompt.
At the command prompt, type
print /d:\\printserver\sharename drive:\path\file name where printserver is the name of your print server, sharename is the name of the shared printer, drive is the name of the drive where the file that you are trying to print is located, path is the directory path to the folder that contains your file, and file name is the name of your file.
Maybe this can be added to autoexec.NT ?
Posted: Mon Jul 26, 2010 9:14 pm
by paydata
Hi Buff1,
After I figured out that the NET USE command was a "DOS" command and not a QB command I typed it in and ran a QB45 program that calls for LPT3. It did work, although there was a delay before the printer responded. I am also researching other things that need to be done like disabling the reroute, if need be, adding LPT1, LPT2, can it be done within QB45 with a SHELL, etc.
Thank you for the tip. I hope this enables me to run all my programs as far as printing is concerned. I think that I will run into other issues along the way, but that's half the fun.
Printing to network printer
Posted: Thu Jul 29, 2010 10:17 am
by I Daniel
Good morning Paydata
(Local time)
The delay in printing is usually caused by the OS spooler. You could try setting the printer options to - print directly to printer - for instance but how will it affect the other Network users and the OS may still put it in a queue, even doing a local print on XP does not always start immediately. If you use SHELL from within a QB45 prog u will have to click your prog on the Task bar since it gets minimized when the SHELL prog finishes. I have not yet tried editing/adding the NET USE to the autoexec.NT file but I think it should work.
Posted: Thu Jul 29, 2010 7:10 pm
by paydata
Hi Daniel,
Thanks for the printer option advice. I will try it as soon as I can. On Tuesday my 14 yr. old dog passed away and this week has been an ordeal for me. I haven't been able to get anything done, much less trying to get my new XP computer up and running QB.
Phil
Posted: Wed Aug 04, 2010 3:46 pm
by paydata
Thanks Daniel,
I'm still having problems with NET USE and LPTx. I set up LPT1, 2 and 3 with NET USE and added "persistent" to them all. When I ran a very small QB45 program for a test, it worked fine for LPT1, but when I changed the 1 to a 3, I got a "Device fault" error in QB5.
BTW: I found an explanation to the annoying pause before printing was because I hadn't included an "END" command at the end of my little QB45 test program and the computer had to wait for a time-out before it could start printing. My bad. This also was not a problem in Win98 (very forgiving).
Phil
printing to a network/shared printer from QB on Xp
Posted: Wed Aug 04, 2010 5:08 pm
by I Daniel
This is just another guess.
In XP under >Start >Settings >Printers and Faxes - Are all three printers listed ? If not try adding them. You will most probably have to set one of them as the default printer. How it will affect printing to the other printers I don't know.
In The Printers and Faxes Window you can also click on Help
and do quite a bit of reading on the subject. (Is this a :- Teach a man to fish and not give him a fish reply ?).
Perhaps there is a Server/Network Boffin/Manager/Specialist viewing this who could help with better/more direct advice ?
Posted: Wed Aug 04, 2010 7:05 pm
by paydata
Good news!
I tried that same little test QB45 program this morning, and it worked.
I printed to the LPT1 printer and to the LPT3 printer.
I retrieved data from the #1 computer disk and printed to both printers. I did the same with data from computers #2, and #3. ????? Maybe it's because I rebooted today? I don't know. Maybe because it"s Wednesday, for all I know. I'm just happy that I can use QB45 on an XP computer.
To recap:
I set up a Batch program to use every time I log-on to the "Command" ("DOS") screen, utilizing the "NET USE" command to redirect the drive letters of all 3 computers and the LPTx's to the computer/server to which the printers are connected. I ran a fairly complex QB45 program and it worked as well.
Thank you to all that have contributed to my new found knowledge base. I'll let you know if I come across any new issues when I put this XP computer into production. Long Live QB45, the Basic language that will never die. I hope.
Phil
network/shared printer using qb on XP
Posted: Wed Aug 04, 2010 7:34 pm
by I Daniel
Yum. Yum
Am I asking to much to request you to post your Batch file here then I will also know how. Remember I am an ancient with holes in my memory and apart from that I am lazy. (see my Flintstone image).
Posted: Wed Aug 04, 2010 11:11 pm
by paydata
My Batch file, that I run every time I log-on to the "Command" ("DOS") screen, looks like this:
-------------------------------------------------------------------------------------
MODE CON COLS=80 LINES=25 ' Set the screen to 80 char. by 25 lines.
DOSKEY ' To retrieve previously typed DOS commands w/ arrow keys.
NET USE G: \\comp1\c_comp1 ' Drive G: = disk drive C: on computer #1
NET USE H: \\comp2\c_comp2 ' Drive H: = disk drive C: on computer #2
NET USE LPT1: \\comp1\HP1 ' LPT1 = printer #1 attached to computer #1
NET USE LPT2: \\comp1\HP2 ' LPT2 = printer #2 attached to computer #1
NET USE LPT3: \\comp1\HP3 ' LPT3 = printer #3 attached to computer #1
NET USE /Persistent:Yes ' remember network connections after reboot (not really needed for I run this .bat every log-on)
NET USE ' print results to screen
-------------------------------------------------------------------------------------
Keep in mind that this .bat is on computer #3 (XP) and is meant to connect computer #3 to #1 and #2.
After I log onto "DOS" by typing COMMAND in the "run" box then I hit ALT+ENTER to get full screen.
I keep this .bat file on my root directory - so therefore I need to type CD\ first.
Then I type the name of this .bat to execute it.
Then I type CD\QB45 to go to the QB45 directory.
Phil.
QB45 on XP: Using a network/shared printer on QB
Posted: Thu Aug 05, 2010 8:19 am
by I Daniel
1. Thanks Phil
Drive G: and H: This means you mapped the other PC's drives. I didn't think of that.
2. Thanks Buff1 for getting us on the right track.
3. I told u I am lazy. I added PAUSE as the last line to see what happens. (The MODE CON isn't really necessary) Then I dragged the BAT file to the Desktop and said - make shortcut. Now I double click the shortcut without having to do Start > Run etc.
I always make a shortcuts for COMMAND prompt (CMD.exe), QB.exe and WORDPAD on my Desktop.