×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Printing a Text file from Qbasic while also archiving the file

Printing a Text file from Qbasic while also archiving the file

Printing a Text file from Qbasic while also archiving the file

(OP)
I have written a data acquisition system, and right now it creates the text file "data.txt" and I have a batch program where the qbasic program runs and then "copy data.txt lpt1"
Works fine, but now I want to specifically name and save the text file for archiving purposes.

This is what I have:

open "data.txt" for output as #3

Then the batch file copies it to LPT1 outside of Qbasic. But the batch file points specifically to data.txt

What I want:

input "filename"; name$     'How do I add the ".txt so the operator doesn't have to type it? Or do I even need the .txt?

now how do I get the whole file to the printer within Qbasic?  I have seen posts on OPEN "LPT1:BIN" FOR OUTPUT AS
but then that only copies one variable to the printer.  Can the whole text file be contained in one varible?

Thanks for all your help!!

Dammit, Jim, I'm an engineer-not a programmer!!

RE: Printing a Text file from Qbasic while also archiving the file

(OP)
OK-Here's an update of what I tried today:

INPUT "What Cartridge"; cart$  (The response I typed was 305)
OPEN cart$ FOR OUTPUT AS #3
OPEN "LPT1" FOR OUTPUT AS #5
PRINT #3 BLAH BLAH BLAH (all my data from the data acquistion, multiple PRINT #3 statements, some strings, some numbers, formatted in tabular output)
CLOSE 1,2,3,4
PRINT #5, cart$
CLOSE 5

Can anyone guess what printed??

"305" on the top of the page-that's it.

If I OPEN "data.txt" FOR OUTPUT AS #3, then all of my data is in a file named data.txt that I view/copy/print many ways.  But I want to replace the filename with a user supplied name, so that it has meaning and we have a record of it, in this case, I was hoping for a file named "305" that held all of my data.
I hope I am explaining this clearly enough.  Please ask me questions if don't understand what I am trying to do!!  I may not understand what I am trying to do!!

RE: Printing a Text file from Qbasic while also archiving the file

How about print #3 and lprint of the same data?
input"filename";fn$:f$=fn$+".txt"
These from gwbasic.

Ed Fair
Any advice I give is my best judgement based on my interpretation of the facts you supply. Help increase my knowledge by providing some feedback, good or bad, on any advice I have given.

RE: Printing a Text file from Qbasic while also archiving the file

INPUT "What is the name of the file?", file$
IF LCASE$(RIGHT$(file$, 4)) <> ".txt" THEN file$ = file$ + ".txt"  

RE: Printing a Text file from Qbasic while also archiving the file

(OP)
Thanks for the help!!

I will try LPRINT- I think I was making it harder than it needed to be.

I will try the code to add the .txt  
I thought that with strings you couldn't just "+" add something-only numbers

RE: Printing a Text file from Qbasic while also archiving the file

1) after
OPEN cart$ FOR OUTPUT AS #3
OPEN "LPT1" FOR OUTPUT AS #5
you can double all your
PRINT #3
lines as
PRINT #5.

2) Or you can skip  
OPEN "LPT1" FOR OUTPUT AS #5
part and instead after closing files issue commands

   cmd$="copy "+cart$+" lpt1"
   shell cmd$

(that is, same as your batch file did, but  from Basic)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close