home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / lan / nxcopy / utvread.mod < prev    next >
Text File  |  1987-03-17  |  2KB  |  62 lines

  1. Module Var_Read;
  2.  
  3.   Const
  4.         {$I UTCONSTS.DEF}
  5.  
  6.   Type
  7.         {$I UTTYPES.DEF}
  8.  
  9.         Reg         =  RECORD
  10.              A      :  Register;
  11.              B      :  Register;
  12.              C      :  Register;
  13.              D      :  Register;
  14.              SI     :  Word;
  15.              DI     :  Word;
  16.              BP     :  Word;
  17.              DS     :  Word;
  18.              ES     :  Word;
  19.              Flags  :  Word;
  20.         End;  {  Record declaration  }
  21.  
  22.   Var
  23.         {$I UTEVARS.DEF}
  24.  
  25.         {$I UTPROCS.DEF}
  26.  
  27.         {       Type conversion utilities for address arithmetic        }
  28.   EXTERNAL Procedure Intr( Intr_No : Integer; VAR Regs : Reg );
  29.   EXTERNAL Function Segm( Variable : StringPtr ) : Integer;
  30.   EXTERNAL Function Offs( Variable : StringPtr ) : Integer;
  31.  
  32. {==============================================================================}
  33.  
  34. Procedure DOS_VRead( Handle  :  Integer;  Buffer  :  StringPtr;
  35.                      VAR Bytes_Requested   :  Integer;
  36.                      VAR Error        :  Integer );
  37.   Var
  38.      R      :  Reg;
  39.   Begin
  40.      R.A.H := $3F;                     {  function for READ                   }
  41.      R.B.X := Handle;
  42.      R.C.X := Bytes_Requested;
  43.      R.D.X := Offs( Buffer );          {  where to transfer data  -  offset   }
  44.      R.DS  := Segm( Buffer );          {                             segment  }
  45.      Intr( $21, R );
  46.      If ( ( R.Flags & 1 ) = 1 ) Then   {  test carry flag                     }
  47.        Begin
  48.           Error  := Short( Long( R.A.X ) ); {  if carry set, error returned in AX  }
  49.           Bytes_Requested := 0;
  50.        End
  51.      Else
  52.         Begin
  53.           Error  := 0;
  54.           {  Also, actual "number of bytes read" returned in AX if no error   }
  55.           Bytes_Requested := Short( Long( R.A.X ) );
  56.         End
  57.   End;
  58.  
  59. {==============================================================================}
  60.  
  61. MODEND.
  62.