how to view output while program is running

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
pronoland
Newbie
Posts: 6
Joined: Sat Feb 10, 2007 1:16 pm
Location: FRIENDLY FRIDLEY MN USA

how to view output while program is running

Post by pronoland »

How can I see my output as it is being generated? is there any way I can view my output file (either the one generated by the PRINT command, or the one generated by theWRITE command?
new user, but willing to learn
moneo
Veteran
Posts: 451
Joined: Tue Jun 28, 2005 7:00 pm
Location: Mexico City, Mexico

Re: how to view output while program is running

Post by moneo »

pronoland wrote:How can I see my output as it is being generated? is there any way I can view my output file (either the one generated by the PRINT command, or the one generated by theWRITE command?
Well, "as it is being generated", is a bit tough if what you mean is to see it on the fly. However, if you'll settle for being able to review all the generated output at the end, you can add a little "audit trail file" or "log file" to your program.

Open a file for output, and call it "log". Everytime the program outputs something, either to the screen or to an output file, write the same data to the log file. If you output both to the screen and a file, or multiple files, prefix the data with the word "screen:" or "File1:" or "file2:". Later when you review the log file, you can tell where the data was written to.

If your program also has keyed input which afects the output, you can also write this keyed data onto the log file with a prefix like "keyin:".

If your program has an input file which it reads, and which is related to the output that it generates, you can also write this input data to the log file with a prefix like "input:".

If you do all this, then after the program is run, you can review the log file with any text editor and see everything that went on. To make it even more attractive, you can prefix every record onto the log file with a date and time stamp. Such a complete log file can be called an "audit trail" file because it shows everything that happened and when it happened.

Regards..... Moneo
User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Just print it to the screen also

Post by burger2227 »

Wherever you produce output, also print it to the screen.
Example
PRINT #1, "Total: "; TotalSales
would be changed to
PRINT #1, "Total: "; TotalSales
PRINT "Total: "; TotalSales
moneo
Veteran
Posts: 451
Joined: Tue Jun 28, 2005 7:00 pm
Location: Mexico City, Mexico

Post by moneo »

... just testing ...
Antoni
Veteran
Posts: 132
Joined: Wed Jun 15, 2005 3:01 pm
Contact:

Post by Antoni »

Just print everything to screen. If you need after to put it into a file you could redirect the screen when calling the program

myprogram >textfile.txt
sid6.7
Veteran
Posts: 318
Joined: Tue Jun 21, 2005 8:51 am
Location: west USA
Contact:

Re: Just print it to the screen also

Post by sid6.7 »

burger2227 wrote:Wherever you produce output, also print it to the screen.
Example
PRINT #1, "Total: "; TotalSales
would be changed to
PRINT #1, "Total: "; TotalSales
PRINT "Total: "; TotalSales

what you can also do is add a pause to this.....


so the program prints one line of output to the screen..pauses
then prints another line...pauses....then your output slowly
scrolls down your screen so you can view it....

look up SLEEP for a quicky way to do it.....
Post Reply