From: marcov@stack.nl   
      
   On 2005-02-06, Bill Leary wrote:   
   >>   
   >> Still, I always wondered what the benefit was of having separate assign   
   >> and reset/rewrite procedures. A legacy thing I guess.   
   >   
   > That's not what he's trying to get around. Using the C standard library, I   
   can   
   > "fopen" then do fgets or (if the particular library has it) "fgetline" to   
   read a   
   > line then follow it up with a "fgetc" to read a few characters then   
   "fgetline"   
   > again and so on. That is, I *can* read lines and characters interchangably   
   and   
   > the library keeps track of it all. In many many years of messing with text   
   in   
   > C, I've only found this feature at all useful a couple of times, which is   
   why I   
   > said "perceived." Usually, if you have ANY need to deal with the file as   
   > characters, your need is so tied up in them, that if you STILL need to read   
   > lines as well, you're driven to write a customized line reader anyway.   
      
   The features work fine with TP and friends. You just have to read the help   
   once in a while, and assume less about that all languages are like C and   
   then you'd have noticed that read() and readln() are magic.   
      
   So you don't have to use readch(f,c); and readint(f,i) but just   
      
   read(f,c); // if c is a simple type char/integer/string etc.   
      
   > For myself, if I'm doing a lot of file mucking, I usually write a function   
   > to which I hand a file handle and a name and a read/write flag and let it   
   > do the assign and the reset/rewrite for me. I might put error handling in   
   > there too and make it procedure, so I don't have to have multiple   
   > instances of it all over the program, but I usually use a function and   
   > return simplified (success/failure) results. So, I end up with something   
   > like "FileOpen(Var F: File; W: Boolean; S: String): Boolean;"   
      
   Better make the "w" parameter an enumeration that sets the sharing info too.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|