Computer Science Canada

help on reading and writing to a file in turing

Author:  JustTrying2GetBy [ Sun Oct 24, 2004 5:24 pm ]
Post subject:  help on reading and writing to a file in turing

I am having some trouble getting this program to work. If someone could please help me by finding the fix to the problem.

code:

var name, country : string
var filevar : int
var holdit : string (1)

open : filevar, "a:/animal", put
for counter : 1 .. 2
    put "Please enter name of the #" ,counter, " animal followed by country "..
    get name, country
end for

close : filevar
put ""


open : filevar, "a:/animal", get
put "This is the display for all the animals and countries."
put "When you are ready press Enter to get contents "
put "of the file.."

getch (holdit)
cls
for counter : 1 .. 2
    get : filevar, name, country
    put "Animal= ", name, " Country= ", country
end for
close : filevar

Author:  Delos [ Sun Oct 24, 2004 5:46 pm ]
Post subject: 

Easy.

You opened the file, got the input from the User, then closed the file. At no point did you write anything to it.

code:

put : filevar, name
put : filevar, country


These will be of some use to you:

File Manipulation by Dan
More file manipulation by Delta
High Scores by Dan (good example of file reading/writing


: