1. Reading Text File
I'm trying to read a text file to the screen to the screen with
this code.
-----code starts here
include get.e
object file_num
sequence line
sequence buffer
file_num = open("d:\\fuphoria\\eudata\\hockey.txt", "r")
-- read a text file into a sequence
buffer = {}
while 1 do
line = gets(file_num)
if atom(line) then
exit -- end of file
end if
buffer = append(buffer, line)
end while
puts(1,buffer) -- this produces ex.err:
--D:\EUPHORIA\EUDATA\CASEDATA\CASE2.EX:13
--file_num has not been declared
-- file_num = open("case.dat", "u")
Really strange since file_num HAS been declared.
Steve Elder
2. Re: Reading Text File
That is kind of funny, seeing that there was no mention of an open for
update file mode mentioned in your program.
In any case, I modfied your program on my system so that it runs to list
data on the screen in file hockey.txt...I created my own hockey.txt file in
the SAME directory as the program, so you will have to change it to reflect
the D drive you had it on.
---- source starts
include get.e
atom file_num
object line
sequence buffer
file_num = open("hockey.txt", "r")
-- read a text file into a sequence
buffer = {}
while 1 do
line = gets(file_num)
if atom(line) then
exit -- end of file
end if
buffer = buffer & line
end while
puts(1,buffer) -- this produces ex.err:
-- source ends
David Gay
"A Beginner's Guide To Euphoria"
http://www.geocities.com/SiliconValley/Vista/4346