home *** CD-ROM | disk | FTP | other *** search
- {TITLE: TOKEN RING/TURBO PASCAL}
-
-
- (* TURBO PASCAL PROCEDURES FOR LOCKING/UNLOCKING RECORDS *)
-
-
- { The following procedures are for use on either the IBM PC Network }
- { or the IBM Token Ring Network. PC-DOS 3.1 (3.2 for the Token Ring) }
- { is required. }
-
- { When locking a record in a file, care should be taken to remember }
- { the location that is locked. Failing to unlock an area of a file }
- { (or trying to unlock an area that is not locked) can be messy. }
-
-
-
- Procedure LockRecord(var return_code : integer;
- handle, {file handle...from Turbo FIB}
- loc_hiword, {most sig. 2 bytes of offset into file}
- loc_loword, {and least sig. 2 bytes}
- len_hiword, {most sig. 2 bytes of record length}
- len_loword : integer); { & least sig. 2 bytes}
-
- {the file handle is the first 2 bytes of the Turbo FIB}
-
- {the loc_hiword and loc_loword comprise a 4-byte offset into the}
- {file, telling where the lock should be placed}
-
- {the len_hiword and len_loword parameters comprise a 4-byte length}
- {saying how much of the file should be locked at that location.}
-
- Type
- DOSRegs = record
- Case Integer of
- 0: (ax, bx, cx, dx, bp, si, di, ds, es, Flags : Integer);
- 1: (al, ah, bl, bh, cl, ch, dl, dh : Byte );
- End;
- Var
- registers : DOSRegs;
- Begin
- fillchar (registers, sizeof(registers), 00);
- with registers do
- Begin
- ah := $5C;
- al := $00; {to lock}
- bx := handle;
- cx := loc_hiword;
- dx := loc_loword;
- si := len_hiword;
- di := len_loword;
- End;
- MSDOS (registers);
- return_code := registers.ax;
- End;
-
-
-
- Procedure UnLockRecord(var return_code : integer;
- handle, {file handle...from Turbo FIB}
- loc_hiword, {most sig. 2 bytes of offset into file}
- loc_loword, {and least sig. 2 bytes}
- len_hiword, {most sig. 2 bytes of record length}
- len_loword : integer); { & least sig. 2 bytes}
-
- Type
- DOSRegs = record
- Case Integer of
- 0: (ax, bx, cx, dx, bp, si, di, ds, es, Flags : Integer);
- 1: (al, ah, bl, bh, cl, ch, dl, dh : Byte );
- End;
- Var
- registers : DOSRegs;
- Begin
- fillchar (registers, sizeof(registers), 00);
- with registers do
- Begin
- ah := $5C;
- al := $01; {to unlock}
- bx := handle;
- cx := loc_hiword;
- dx := loc_loword;
- si := len_hiword;
- di := len_loword;
- End;
- MSDOS (registers);
- return_code := registers.ax;
- End;
-