home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / lan / spoolit / lock.pas < prev    next >
Pascal/Delphi Source File  |  1987-02-15  |  3KB  |  58 lines

  1. { These routines are designed for use with version 3.x of Turbo Pascal
  2.   running under DOS 3.x.  These routines can be used with any typed file
  3.   (e.g. var CustFile: file of CustRec) but not with untyped or text files.
  4.   These routines may be used on Borland Database Toolbox files of type
  5.   DataFile.
  6.  
  7.   Scott Bussinger
  8.   Professional Practice Systems
  9.   110 South 131st Street
  10.   Tacoma, WA  98444
  11.   Compuserve [72247,2671]  }
  12.  
  13. function LockRec(var Fyle; RecNum:integer): boolean;
  14.   { Lock record RecNum in Fyle using DOS 3.x function call.  Returns
  15.     true if lock successful, false if error was detected. }
  16.   begin
  17.   inline(
  18.     $C4/$9E/>Fyle/   {  LES  BX,[BP][>Fyle]   ; Get pointer to Turbo FIB }
  19.     $BE/$00/$00/     {  MOV  SI,0             ; High word of length always 0 }
  20.     $26/$8B/$47/$02/ {  ES: MOV  AX,[BX][2]   ; Get low word of record length }
  21.     $89/$C7/         {  MOV  DI,AX            ; Length of lock now in SI:DI }
  22.     $8B/$96/>RecNum/ {  MOV  DX,[BP][>RecNum] }
  23.     $F7/$E2/         {  MUL  DX               ; RecLen times RecNum is offset }
  24.     $89/$D1/         {  MOV  CX,DX            ; Move 32 bit result into CX:DX }
  25.     $89/$C2/         {  MOV  DX,AX }
  26.     $26/$8B/$1F/     {  ES: MOV  BX,[BX]      ; Grab the file handle from FIB }
  27.     $B8/$00/$5C/     {  MOV  AX,$5C00         ; Record Lock function }
  28.     $CD/$21/         {  INT  $21              ; Call DOS }
  29.     $B0/$00/         {  MOV  AL,0             ; Convert carry flag to Pascal }
  30.     $72/$02/         {  JC   Done             ;    true/false }
  31.     $FE/$C0/         {  INC  AL}
  32.                      { Done: }
  33.     $88/$46/$0A)     {  MOV  [BP][10],AL      ; Stuff into function result }
  34.   end;
  35.  
  36. function UnlockRec(var Fyle; RecNum:integer): boolean;
  37.   { Unlock previously locked record RecNum in Fyle using DOS 3.x function
  38.     call.  Returns true if unlock successful, false if error was detected. }
  39.   begin
  40.   inline(
  41.     $C4/$9E/>Fyle/   {  LES  BX,[BP][>Fyle]   ; Get pointer to Turbo FIB }
  42.     $BE/$00/$00/     {  MOV  SI,0             ; High word of length always 0 }
  43.     $26/$8B/$47/$02/ {  ES: MOV  AX,[BX][2]   ; Get low word of record length }
  44.     $89/$C7/         {  MOV  DI,AX            ; Length of lock now in SI:DI }
  45.     $8B/$96/>RecNum/ {  MOV  DX,[BP][>RecNum] }
  46.     $F7/$E2/         {  MUL  DX               ; RecLen times RecNum is offset }
  47.     $89/$D1/         {  MOV  CX,DX            ; Move 32 bit result into CX:DX }
  48.     $89/$C2/         {  MOV  DX,AX }
  49.     $26/$8B/$1F/     {  ES: MOV  BX,[BX]      ; Grab the file handle from FIB }
  50.     $B8/$01/$5C/     {  MOV  AX,$5C01         ; Record Unlock function }
  51.     $CD/$21/         {  INT  $21              ; Call DOS }
  52.     $B0/$00/         {  MOV  AL,0             ; Convert carry flag to Pascal }
  53.     $72/$02/         {  JC   Done             ;    true/false }
  54.     $FE/$C0/         {  INC  AL}
  55.                      { Done: }
  56.     $88/$46/$0A)     {  MOV  [BP][10],AL      ; Stuff into function result }
  57.   end;