
-----------------------------------
anna12345
Wed Apr 16, 2008 10:23 am

Data files
-----------------------------------
I don't understand how data files work . I've read the tutorial but I still don't get it. How do you create a new file and then open it. For example I need to create a program that records your score. So you can see your score after. Can someone explain how to do a program like that? I'm extremely confused 

Here's the code

type high_type:

record
 street:string(7)
 name:string
 score:int
end record

var high: array 1..5 of high_type
for i:1..5
high(i). street:= "Laurier"
high(i). name:= "Anna"
high(i). score:=100
end for

var f1:int
open:f1, "Read Data", write
for i:1..5
write: f1, high(i)
end for
close: f1

open : f1, "Reid_Data", read        
for i : 1 .. 5                     
    read : f1, high (i)
end for
close :f1

-----------------------------------
BigBear
Mon Apr 21, 2008 5:41 pm

Re: Data files
-----------------------------------
When you use open: filenumber, filename, put you create the file and can now put information in it.
then you put :fn ,  name - 1200
and it will record the score. then you just read the ile and put it on the screen to view text files.
