Re: HELP with 'seek'
- Posted by Robert Craig <rds at ATTCANADA.NET> Aug 18, 2000
- 489 views
Jim writes: > I'm having a problem in using the 'seek' function... > ...DataFile = open(fullpath,"r") -- open for reading When you use seek(), you have to keep track of byte offsets within a file very carefully. Opening a file as "r" (read in text mode) is going to cause you no end of trouble. It would be better to open the file as "rb" (read in binary mode) and realize that each line of text (each record) normally ends with two characters: \r\n. I believe seek() looks at all the characters in the file, whereas gets() will only "see" \n, not \r\n as is actually stored in the file. The division of I/O on DOS/Windows into "text" vs. "binary" modes was completely unnecessary, and has caused confusion for many years. I guess it was a quick kludge to make some IBM printer work better, back in the early 80's. Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com