"Wrapper" for gets()
- Posted by Juergen Luethje <j.lue at gmx.de> Aug 05, 2003
- 361 views
Hi all, I just want to share the following function: function getx (integer fn) -- "wrapper" and replacement for gets() -- This function combines the advantages of reading lines -- o in text mode: A line looks always the same, regardless whether -- in the file it actually ends with "\n" or with "\r\n". -- o in binary mode: No problems with ASCII 26 (EOF). -- -- in : number of a file, that was opened for reading in binary mode -- out: a line, as if it were read in text mode object line integer x line = gets(fn) if sequence(line) then x = length(line)-1 if x > 0 and line[x] = '\r' then line[x] = '\n' return line[1..x] end if end if return line end function Best regards, Juergen -- The difference between men and boys is the price of their toys.