
-----------------------------------
JustTrying2GetBy
Sun Oct 24, 2004 5:24 pm

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.


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


-----------------------------------
Delos
Sun Oct 24, 2004 5:46 pm


-----------------------------------
Easy.

You opened the file, got the input from the User, then closed the file.  At no point did you write anything to it.


put : filevar, name
put : filevar, country


These will be of some use to you:

[url=http://www.compsci.ca/v2/viewtopic.php?t=5]File Manipulation by Dan
[url=http://www.compsci.ca/v2/viewtopic.php?t=427]More file manipulation by Delta
[url=http://www.compsci.ca/v2/viewtopic.php?t=5340]High Scores by Dan (good example of file reading/writing
