OPENING A FILE TO SAVE RESULTS

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
LEGRAND
Coder
Posts: 49
Joined: Wed Jul 30, 2008 7:57 am

OPENING A FILE TO SAVE RESULTS

Post by LEGRAND »

This one probaly easy,but I don't find the way. My files opened, with instruction OPEN "O",#1 ,"***" but I don't never know ...where, I mean in what folder. To assure it will open in "my documents" for instance, what is the correct instruction?
2. How to do to avoid repeating lines you want to see to appear both on screen and in the file your program opened:
PRINT "WHATEVER"
PRINT#1,"WHATEVER"
and even a third time on the printer:
LPRINT"WHATEVER"
Is there a way to get it with only one instruction?
Thanks for help.
User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 »

You can either move the program to the path folder or use a path from the root of the drive in the OPEN statement. The root would most likely be "C:\MyDocu~1\filename.txt"

Why do all three things at once? You are gonna waste a lot of paper and ink if you print everything at once. What I would do is PRINT it to the screen and PRINT # it to a file. Maybe preview it before printing the file.

Save the text to an array and make SUB procedures to do the work. Each can be chosen from a simple menu. All three procedures can use USING to work with formatted text. Does LPRINT work for you? You may need to set up a Network printer.

Create the text file first and use SHELL to open it in Notepad. Then PRINT it using Notepad or SHELL

SHELL "CMD /C START Notepad ABC.txt" 'preview

SHELL "CMD /C START /min Notepad /p ABC.txt" 'printer

Ted
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
LEGRAND
Coder
Posts: 49
Joined: Wed Jul 30, 2008 7:57 am

OPENING QB FILE

Post by LEGRAND »

Looks fine.Thanks.
By the way, yes, my LPRINT works.
Post Reply