peg@psuecl.bitnet (PAUL E. GANTER) (04/13/90)
Help, please! I am trying to read sequential text files on my Amiga using Benchmark Modula 2. I prefer to read a whole line at a time, so I wrote a ReadLine procedure. When I repeatedly call it, it reads the same (first) line of the text file! I am NOT reopening the file or using SetPos between ReadLine's. If you have any idea why this is happening, please help! ReadLine is something like: x := 0 repeat readchar(infile,ch) line[x] := ch inc(x) until infile.eof or ch = lf line[x] := char(0) It seems to work okay on the first line. WriteString will show the first line as expected. The calling code is something like: repeat readline(in,ln) writestring(ln) . . . until in.eof --------------------------------------------------------------------- Please e-mail help, as I don't normally read this group! Thanks! --Paul peg@psuecl.bitnet or peg@psuecl.psu.edu
peg@psuecl.bitnet (PAUL E. GANTER) (04/13/90)
Help, please! I am trying to read a sequential text file in Benchmark Modula 2 on an Amiga. I wante dto read a whole line at a time, so I wrote a ReadLine procedure (below). When I call this routine repeatedly, the same (first) line is read from the file each time. Can anyone explain why this is? I am not reopening the file each time, or using SetPos between ReadLine's. ReadLine is something like: x := 0 repeat readchar(infile,ch) line[x] := ch inc(x) until infile.eof or ch = lf line[x] := 0 the calling code is now (i simplified it): repeat readline(file,ln) writestring(ln) check for control c to save my butt! until file.eof Please e-mail any help, since I don't normally read this. Thanks! --Paul peg@psuecl.bitnet peg@psuecl.psu.edu