home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 8
/
CDASC08.ISO
/
NEWS
/
554
/
MAI
/
TEXTSEEK.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1993-10-07
|
2KB
|
61 lines
{─ Fido Pascal Conference ────────────────────────────────────────────── PASCAL ─
Msg : 349 of 412
From : Marco Miltenburg 2:512/169.0 14 May 93 09:44
To : Raphael Vanney 2:320/7.0
Subj : Pardon if repeat
────────────────────────────────────────────────────────────────────────────────
Hi Rapael,
> One cannot seek in a text file...
Sure you can... For DOS, textfiles are really the same things as typed
files, so why don't ask DOS ;-) ? Try this one. F is a textfile and n is the
file-offset.}
Procedure tSeek(Var f:Text; n:LongInt); Assembler;
Asm
push DS
push BP
lds SI,f
lodsw { handle }
mov BX,AX
mov CX, word ptr [BP+8]
mov DX, word ptr [BP+6]
mov AX,4200h {AL = 2, AH = 42}
int 21h
les DI,f
mov AX,DI
add AX,8
mov DI,AX
lodsw { mode }
lodsw { bufsize }
mov CX,AX { CX = number of bytes to read }
lodsw { private }
lodsw { bufpos }
lodsw { bufend }
lodsw { offset of pointer to textbuf }
mov DX,AX { DX = offset of textbuf }
lodsw
mov DS,AX { DS = segment of textbuf }
mov AH,3Fh
int 21h
push AX { Save AX on stack }
les DI,f { ES:DI points to f }
mov AX,DI { Move pointer to position 8 }
add AX,8
mov DI,AX
mov AX,0 { Bufpos = 0 }
stosw
pop AX { Bufend = number of bytes read }
stosw
pop BP
pop DS
End; { tSeek }