Re: Creating A File To Be Written/Read From
- Posted by Andy Dec 14, 2008
- 1140 views
euphoric said...
Andy said...
OK,
Well I'm making my own program which needs to load and read a certain file. Which the extension I have given is .frst, anyways I need to know how I would go about doing that.
Off the top of my head...
atom fn object line sequence lines -- to write it fn = open("filename.frst","w") if fn != -1 then puts(fn,"What you want to put in the file here...") close(fn) end if -- to read it with version 3.x fn = open("filename.frst","r") line = gets(fn) while sequence(line) do lines &= line line = gets(fn) end while -- to read it with version 4.x include std/io.e lines = read_lines( "filename.frst" ) -- or lines = read_file( "filename.frst" ) -- see docs for differences
That should get you started.
Thanks, I'm getting a better idea now.