Looping thru file with 'gets()' fails to retrieve last record

new topic     » topic index » view thread      » older message » newer message

I have an Ascii text file in the cgi-bin with exactly 3,772 records in it.

I have tried the two approaches below to read it.....both fail to return
the last record before posting a '-1' to the file handle. Both return
exactly 3,771 records instead of 3,772 ??

            First, the file is opened and one record read: 
integer fn
sequence line 	
fn=open("bcare_remit.txt","r")
if fn > 0 then
  line = gets(fn)    <----- 1st record retrieved here
else
  puts(1,"Unable to open the disk file\n")
  abort(1)
end if 	


    The above is followed by either of the two loops below:
#1:

while sequence(line) do
  ......process...
  line = gets(fn)
end while

            
#2:

for 1 = 1 to 3772 do
  ......process...
  line = gets(fn)
end for


new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu