
-----------------------------------
recneps
Sat Feb 07, 2004 11:59 am

Help with file input/output
-----------------------------------
Ok, heres my problem. I'm doing a test to see how the input/output to a file works, and i can output 2 variables, but i cant get 2 variables. Should i be able to ? If so, why isnt it working, it says "attempt to read past eof"

heres my code:
var filenum, filename, iocapacity, streamin, streamout : int
var test : string
var price : real
price := 29.99
test := "item"
open : streamout, "test.txt", put
put : streamout, test, price

close : streamout

open : streamin, "test.txt", get
get : streamin, test, price

close : streamin
put test, price


-----------------------------------
AsianSensation
Sat Feb 07, 2004 12:16 pm


-----------------------------------
when you are doing this: put : streamout, test, price you have outputted the information on 1 line, so when you tried to get it, test now becomes "item29.99" and there isn't any info for you to get on the next line, so that gives you an error.

put : streamout, test, '/n', price doing this will output an endline character, and it skips a line in the textfile.

edit: or, as dodge suggested, you can use skip instead of '/n'.

-----------------------------------
Andy
Sat Feb 07, 2004 12:30 pm


-----------------------------------
azn, who uses \n in turing? just do skip

-----------------------------------
recneps
Sat Feb 07, 2004 6:45 pm


-----------------------------------
Thanks guys, I'm gonna try make a cash register for my mom :) So i can make a receipt with item name and price , etc :)
