Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
save/read/print off disk......
#1
making a grade sheet! save the score a person took each time and save it, print all the grades out in one screen, anyone can show me one example?
Reply
#2
I would use OPEN.

To save data, use

OPEN "file.txt" FOR OUTPUT AS #1
PRINT #1, score(or other variable)
CLOSE #1

To load data, use

OPEN "file.txt" FOR INPUT AS #1
INPUT #1, score(or other variable)
CLOSE #1
Reply
#3
Be careful with OPEN FOR OUTPUT. When you open a file for output it gets rid of data already in the file. You'd want to use this:

Code:
INPUT "Enter score you wish to add to the list: ", Score
OPEN "scores.txt" FOR APPEND AS #1
   PRINT #1, Score
CLOSE #1

This code will allow you to keep adding scores to the end of the list without erasing previous entries.

Then, to read the scores:

Code:
OPEN "scores.txt" FOR INPUT AS #1
     DO
          INPUT #1, Score
          PRINT Score
     LOOP UNTIL EOF(1)
CLOSE #1

Alternatively, you could just print the file "scores.txt" to get a printed list of scores.

*peace*

Meg.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)