output to word

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
boominz28
Newbie
Posts: 1
Joined: Mon Oct 16, 2006 11:40 am

output to word

Post by boominz28 » Mon Oct 16, 2006 12:08 pm

We use qbasic to do some engineering for us and at the end of the program it asks to print. i would like instead of printing to save it or send it to word so i can save the file and print when i want. i would love to send someone the program so they can tell me how to do this. :?:

bungytheworm
Veteran
Posts: 288
Joined: Sat Feb 18, 2006 4:02 pm

Post by bungytheworm » Mon Oct 16, 2006 12:34 pm

If you want simple thing that saves your output (i guess it's variable?), then just look OPEN and #PRINT functions.

You can also post your code here and we tell you how to move on.

User avatar
Patz QuickBASIC Creations
Veteran
Posts: 399
Joined: Wed Mar 02, 2005 9:01 pm
Location: Nashville, Tennessee
Contact:

Re: output to word

Post by Patz QuickBASIC Creations » Mon Oct 16, 2006 3:50 pm

Code is usually helpful.

Like lurah said, it probably just needs a couple OPEN, PRINT #, and CLOSE statements somewhere...

moneo
Veteran
Posts: 451
Joined: Tue Jun 28, 2005 7:00 pm
Location: Mexico City, Mexico

Re: output to word

Post by moneo » Mon Oct 16, 2006 5:04 pm

boominz28 wrote:We use qbasic to do some engineering for us and at the end of the program it asks to print. i would like instead of printing to save it or send it to word so i can save the file and print when i want. i would love to send someone the program so they can tell me how to do this. :?:
If I understand you correctly, the program already prints some results. You didn't say whether it prints to the screen on to the printer, but it's basically the same thing.

To print these results to a file, I'll give you some simple ideas.

1) Near the top of the program, before the code for the main program starts, issue an OPEN statement for the file that will contain the results, like so:
OPEN "RESULTS.TXT" FOR APPEND AS #6
I chose a file extension of .TXT to make it simpler to import the file into NOTEPAD or WORD.
I chose OPEN FOR APPEND so that you can run the program several times and see the results of these several runs, one right after the other. To identify these separate runs with a date and time, right after the OPEN you can print the date and time to the results file as follows:
PRINT #6,DATE$;" ";TIME$

2) Now, find where in the program it is now printing results. You can either leave the existing printing as is, or you can replace it. Take each existing PRINT or LPRINT statement and copy it, substituting the PRINT or LPRINT part with PRINT #6,

3) That's it. You really don't need to close file #6. It will be closed automatically when your program terminates with an END or SYSTEM.

You now have a running backup of your results in the RESULTS.TXT file which you can save, or load into NOTEPAD or WORD. When you don't want anymore results added on the end of the file, just delete the RESULTS.TXT file before running the program.

Good luck.

Post Reply