From: nospam@tiscali.nl   
      
   "HubbleBubble" wrote in message   
   news:1179916962.034090.22760@o5g2000hsb.googlegroups.com...   
   > Hi All,   
   >   
   > One thing that I can't figure out is the text vs binary thing.   
   > As you know in dos a file handle is just an integer. Presumably this   
   > points to an internal record of type file or does the user need to   
   > optionally supply a pointer to a file structure?. Is the text record   
   > structure part of dos or is it handled entirely by pascal?. If it is   
   > dos how might I tell dos which type of file I want?   
   >   
   The difference is made in the filetype   
   Textfiles are type TEXT in BP7 (or TextFile in Delphi)   
   Binary files are File of Byte.   
      
   You can read a number of bytes and then convert them to any other type by   
   using one of the following tricks:   
      
   - dereference a pointer into a variable of the other type, this will work   
   with any variable, even large records.   
   - use a variant record, like   
      
   s = record   
    case Byte of   
    0: ( sa : array [1..4] of Byte );   
    1: ( res : Single );   
    end;   
      
   var u: s;   
      
   You can now read the four bytes from your binary file, and set them like   
   u.sa[1]:=byte1; etc., and then access the single precision real with u.res   
      
   Turbo Pascal used this trick to access the registers, either 8 bit or 16 bit   
   wide.   
      
   type   
    Registers = record   
    case Integer of   
    0: (AX, BX, CX, DX, BP, SI, DI, DS, ES, Flags: Word);   
    1: (AL, AH, BL, BH, CL, CH, DL, DH: Byte);   
    end;   
      
   HTH, Matt   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|