Help with file input/output
Author |
Message |
recneps
|
Posted: Sat Feb 07, 2004 11:59 am Post subject: 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:
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
|
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
AsianSensation
|
Posted: Sat Feb 07, 2004 12:16 pm Post subject: (No subject) |
|
|
when you are doing this: code: | 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.
code: | 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
|
Posted: Sat Feb 07, 2004 12:30 pm Post subject: (No subject) |
|
|
azn, who uses \n in turing? just do skip |
|
|
|
|
|
recneps
|
Posted: Sat Feb 07, 2004 6:45 pm Post subject: (No subject) |
|
|
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 |
|
|
|
|
|
|
|