Page 1 of 1
Posted: Mon Sep 08, 2008 8:05 am
I cannot print my QBASIC programs. I an running QBASIC in the following envireonment. Windows EP Profesional and my printers are HP Color LazerJet 1600 or a HP Officejet 5610 ALL- in - One. I have tried both HP and Microsoft without sucess.
Your help will be appreciated.
Posted: Mon Sep 08, 2008 11:27 am
What is Windows EP?
The printers must be connected to LPT1 to use LPRINT. Some may still not work correctly. Qbasic cannot use the USB ports directly! There are some other programs that can help for USB printers. Most are not free!
Try creating text files with PRINT # and opening them in Notepad from the SHELL command line. You can print it from there. This way you can choose to print or not while creating your code.
NT and XP limit access to ports. Try using PortTalk (Free) to open a parallel port. Read the documentation in PortTalk to install correctly!
Posted: Mon Sep 08, 2008 1:41 pm
This is basically the same as Ted's idea.
When you are writing your program in Qbasic, you normally save it. This creates a file with a .BAS extension.
Get into Notepad, "open" this .BAS file, and then use "print" to print it.
Of course you have to give Notepad the right path to get to the file.
Posted: Mon Sep 08, 2008 3:37 pm
True Moneo, but the BAS file needs to be saved as Text Readable in the QB Save dialogue box. Otherwise you end up with machine code in Notepad which is useless!
Posted: Sun Sep 14, 2008 9:38 am
I think that the solution given is nice to get from .BAS file copied in note a record of the program 's code. But what I think more useful would be to get in a file the RESULTS of the program's calculations.Otherwise if the data is long enough, all the beginning is lost, remaining on the screen the last values.I read several suggestions to have this printed and understood nothing.What would be probably the best way to progress in that question would be to get the full code to add to any program in order to have results printed. If there is a port issue with WIN XP, read you can do it using the command SHELL. Once again would be great to have the compete code lines in order to try to understand how to do it. Tnanks to any help
Posted: Sun Sep 14, 2008 10:23 pm
There is a way to print to USB printers from DOS.
I do not remember the command off the top of my head.
Just go search google for DOS USB PRINTER.
I think it has something to do with assigning the LPT1 to use the USB, but I've seen it done, and have done it before ages ago. I just don't remember right now what it was.
If you can't find anything, I'll see if I can find it for you.
Posted: Mon Sep 15, 2008 3:44 am
This QB program should set up a Windows session in XP or NT to use data sent to the LPT1 port by LPRINT. Go to the Control Panel - Printers list. First you must set the USB printer Properties to Shared in the Shared Tab and set the Printer Processor mode to Text in the Advanced Tab :
Code: Select all
COLOR 11: LOCATE 2, 20: PRINT "XP USB Printer to assign for LPRINT"
COLOR 10: LOCATE 3, 4: PRINT "In Control Panel, set the USB printer to Shared with Text Format (not RAW)."
Computer$ = ENVIRON$("COMPUTERNAME") 'NT or XP only!
SHELL "NET VIEW " + Computer$
COLOR 14: INPUT " Enter the USB Printer's Share Name from above: ", Printer$
SHELL "NET USE LPT1 \\" + Computer$ + "\" + Printer$ 'send LPT to USB
LPRINT "Test of USB Printer use with LPRINT" + CHR$(10) 'linefeed
LPRINT CHR$(12) ' form feed
This is my crude routine, but it worked on my XP! You can make a batch file to do the NET USE line once you establish the PC name and Printer Share Name. I call it crude, because it has no error handlers. Also you only need to run this once per Windows session when using LPRINT. I wonder if it could work on a COM port also?
I plan to have the routine create the batch file automatically.
Posted: Mon Sep 15, 2008 9:20 am
Thanks both of you.I'll try it soon and see if it can apply to GW BASIC
Posted: Fri Oct 17, 2008 7:51 pm
If you have Windows XP, printing from DOS to a USB printer is possible
and FREE!!! You can also print even if the printer is on a network.
There are programs you can buy to allow you to print from DOS but why
PAY when its already part of Windows XP.
1. Open a command prompt.
2. First, find out the name of your computer.
Type: NET USE
3. Second, know the name of the printer you want to print to. You can
get this information from the Control Panel/Printer and Faxes.
3. For my computer I typed this. You have to type this command to the
computer that you want to print from DOS even if that computer is
on a network.
Note: If you print and the computer hangs...then Windows was not
able to successfully connect to that printer. Type the command
Type: NET USE LPT1 \\Dell\HP /Persistent:Yes
Name of the computer. Change this for the name of
your computer. Remember to include the two \\ in
front of your computer name
Name of the printer. Replace this with the name of
your printer. Only one back-slash.
The /Persistent:Yes parameter will tell Windows to
reestablish the connection when the system is rebooted.
If the printer is not connected to the computer when
it boots, Windows will usually remember the connection
anyway. Depending on your system's defaults and
security settings, Windows might even ask if you want
to have the printer connection deleted when Windows
can't find the printer anymore.
If everthing works, you should be able to print from within the IDE
environment just by sending your print jobs to LPT1.
At the command prompt you can still print doing it the old way...
c:\type sample.bas > lpt1:
c:\type sample.txt > prn
c:\dir *.bas > lpt1:
If you encounter any problems, look up how to use NET USE.
Hope this helps...enjoy.
Posted: Mon Oct 20, 2008 8:23 pm
WHAT do you think my DOS program did? READ the thread!
2. First, find out the name of your computer.
My code finds the COMPUTERNAME for you in Qbasic code!
As for Persistant, I have not found that to be necessary on my XP. After reboot, it works anyway. If you try to do my routine again, I get an error 85.
The only thing keeping the LPRINT command from working is that perhaps the Printer Process box MUST have "Text" as the setting in Windows! For Windows to print something, you may have to change it to LEMF!
LPRINT AND XP
Posted: Mon Apr 05, 2010 3:26 pm
To Burger2227 Was not aware any addition to first answers. So discovered your code this evening and tried it immediately. IT WORKS PERFECTLY !
This is a great improvement for me. Only issue is to adjust the printer properties each time want to use QBASIC and the must boring is probably to have to set to "text" each time which probably if you let it fixed on it, will make all drawing impossible to print from windows (just a guess)
But this is a very good surprise, and I thank you sincerely.
Posted: Mon Apr 05, 2010 3:53 pm
Glad you like it! I know it is a PAIN to set the printer processing from Text to LEMF, but you don't have to touch the Shared Network code.
To remove the shared network setup just add " /Delete" to the end of the NET USE setup string.