Qbasicnews.com
February 23, 2020, 07:29:24 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: 1 2 [3]
  Print  
Author Topic: print to USB  (Read 10168 times)
Ralph
Ancient Guru
****
Posts: 544


« Reply #30 on: August 14, 2005, 08:53:52 AM »

AT THE BEGINNING, CHAOS WROTE:
Quote
Moneo
Na_th_an

Joined: 13 Jun 2003
Posts: 1408
Location: Mexico City, Mexico

 Posted: Sat Jun 04, 2005 12:38 am    Post subject:    

--------------------------------------------------------------------------------
 
Philip,

I scouted around, and several people say that you can't print to a USB directly from DOS, because the USB is a Windows-only device.

I did find this little program, which is basically an automation of my previous solution regarding printing to an intermediate file. I haven't tested it. If it works, it's more elegant than my solution.

----------------------------------------------------------------------------------
Well, this code example should work perfectly fine for all printers, USB included. Windows platform only, of course.

DATAFILE$ = "TEST.TXT"
OPEN DATAFILE$ FOR OUTPUT AS #1
PRINT #1, "Data "
CLOSE #1

SHELL "start /m wordpad /p TEST.TXT"
---------------
The SHELL command is the key to your situation. You can save the output data into a text file, then simply use WordPad with the /p convention to print the file. This should work with any printers installed to Windows......
[quote/]

O.K., we have been going around in circles.  Me, talking about FF CHR$(12), and you about LPRINT, which is a Carriage Return + Line Feed (CR+LF), or CHR$(13)+CHR$(10).  Now, these will send a line to the printer that you have on LPT1, but, even so, the printer there connected, if it is a modern printer, will not print until either it has a full page in memory, or it receives a Form Feed, or FF CHR$(12).

BUT, as Chaos and other knowlegeable have carefull explained to you, QuickBASIC apparently cannot send anything to a USB port.  If that is true, then, STOP, you just can't do it.

Now, using the methods suggest by them, send the one line you want to print out to a text file, close it, and do the SHELL thing they have suggested.  And, if that still doesn't work, then, after closing the text file, open wordpad (or notepad), open the text file and send it to the USB port printer.  



Now, since you can't be serious about printing only one line on each page, I think you should just GIVE UP trying to do so, and just print out your full program, once it's done.

On the other hand, since you mentioned fear of losing your program, why not simply do a Save As to a slightly different named file, say your file is MyTest.BAS, which you save as "Text , readable by other programs", then also do a Save As to a new file, which you will name MyTest2.BAS?  And, you can always print out any of the two files, using the methods explained by Chaos and others.
Logged

Ralph, using QuickBASIC 4.5 and Windows XP Home Edition and Service Pack 2, with HP LaserJet 4L printer.
Moneo
Na_th_an
*****
Posts: 1971


« Reply #31 on: August 14, 2005, 10:24:36 PM »

Quote from: "jelamb"
.....
OK, that works for printing a copy of my program. However, I don't get any output to my printer using the Lprint command.

jelamb,

You're driving Ralph and I crazy. You state a problem, we give you the solution, and then you change to another problem.

Regarding your last statement about "using the Lprint command."
YOU CAN'T USE THE LPRINT TO PRINT TO AN USB PRINTER. PERIOD!
We have told you this before.

1) Open a data file, like PDATA.TXT, for output to receive the output print lines from your program.
OPEN "PDATA.TXT" FOR OUTPUT AS #6

2) Replace all the LPRINT statements in the program with
PRINT #6,print-data

3) When the program completes, take a look at PDATA.FIL to make sure that this is what you want to print out.

4) Get back into Windows, select the PDATA.FIL, and print it to your USB printer, just like you would print any other text file.

What problem do you see with this solution now?
*****
Logged
Anonymous
Guest
« Reply #32 on: August 15, 2005, 12:15:47 AM »

maybe he doesnt wanna leave the IDE. its cold out there u know. :P xD
Logged
Moneo
Na_th_an
*****
Posts: 1971


« Reply #33 on: August 15, 2005, 03:27:13 PM »

Quote from: "Cha0s"
maybe he doesnt wanna leave the IDE. its cold out there u know. Tongue xD

You're probably right, Cha0s.

But as they say: "You can't make an omelette without breaking eggs".

I don't know, but maybe he should explore how Freebasic would handle an USB printer.
*****
Logged
Pages: 1 2 [3]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!