home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Best of German Only 2
/
romside_best_of_german_only_2.iso
/
dos
/
utility
/
bs_pasca
/
getput.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1993-05-09
|
6KB
|
252 lines
UNIT GETPUT;
{ ZUGRIFF AUF UNTYPISIERTE DATEI }
{$F+}
INTERFACE
USES DOS;
VAR FILEERR : WORD;
PROCEDURE FOPEN (VAR F:FILE;S:STRING); { OPEN FÜR INPUT UND OUTPUT }
PROCEDURE FOPENI(VAR F:FILE;S:STRING); { OPEN FÜR INPUT }
FUNCTION FSIZE (VAR F:FILE):LONGINT; { FILEGRÖßE IN BYTES }
FUNCTION FPOS (VAR F:FILE):LONGINT; { FILEPOSITION }
PROCEDURE FSEEK (VAR F:FILE;P:LONGINT); { FILEPOINTER POSITIONIEREN }
PROCEDURE FCLOSE(VAR F:FILE); { CLOSE WENN OFFEN }
PROCEDURE FGET (VAR F:FILE;P:POINTER;S:WORD); { GET ANZAHL BYTES AUS FILE }
PROCEDURE FGETL (VAR F:FILE;VAR L:Longint); { GET LONGINT IN UNTYPISIERTES FILE }
PROCEDURE FGETB (VAR F:FILE;VAR B:BYTE); { GET BYTE }
PROCEDURE FGETO (VAR F:FILE;VAR B:Boolean); { GET Boolean}
PROCEDURE FGETC (VAR F:FILE;VAR C:CHAR); { GET CHAR }
PROCEDURE FGETW (VAR F:FILE;VAR W:WORD); { GET WORD }
PROCEDURE FGETI (VAR F:FILE;VAR I:INTEGER); { GET INTEGER }
PROCEDURE FGETH (VAR F:FILE;VAR W:WORD); { GET WORD HILO- NOTATION }
PROCEDURE FGETR (VAR F:FILE;VAR R:REAL); { GET REAL }
PROCEDURE FGETP (VAR F:FILE;VAR P:POINTER); { GET POINTER }
PROCEDURE FGETS (VAR F:FILE;VAR S:STRING); { GET STRING }
PROCEDURE FGETLN(VAR F:FILE;VAR S:STRING); { GET LINE }
PROCEDURE FPUT (VAR F:FILE;P:POINTER;S:WORD); { PUT ANZAHL BYTES IN FILE }
PROCEDURE FPUTL (VAR F:FILE;L:Longint); { PUT LONGINT IN UNTYPISIERTES FILE }
PROCEDURE FPUTB (VAR F:FILE;B:BYTE); { PUT BYTE }
PROCEDURE FPUTO (VAR F:FILE;B:boolean); { PUT Boolean}
PROCEDURE FPUTC (VAR F:FILE;C:CHAR); { PUT CHAR }
PROCEDURE FPUTW (VAR F:FILE;W:WORD); { PUT WORD }
PROCEDURE FPUTI (VAR F:FILE;I:INTEGER); { PUT INTEGER }
PROCEDURE FPUTH (VAR F:FILE;W:WORD); { PUT WORD HILO- NOTATION }
PROCEDURE FPUTR (VAR F:FILE;R:REAL); { PUT REAL }
PROCEDURE FPUTP (VAR F:FILE;P:POINTER); { PUT POINTER }
PROCEDURE FPUTS (VAR F:FILE;S:STRING); { PUT STRING }
IMPLEMENTATION
PROCEDURE FOPEN(VAR F:FILE;S:STRING); { OPEN FÜR INPUT UND OUTPUT }
BEGIN
ASSIGN(F,S);
{$I-}
RESET(F);
FILEERR := IORESULT;
IF FILEERR <> 0 THEN BEGIN
REWRITE(F);
RESET(F);
FILEERR := IORESULT;
END;
{$I+}
END;
PROCEDURE FOPENI(VAR F:FILE;S:STRING); { OPEN FÜR INPUT }
BEGIN
ASSIGN(F,S);
{$I-}
RESET(F);
FILEERR := IORESULT;
{$I+}
END;
FUNCTION FSIZE(VAR F:FILE):LONGINT; { FILEGRÖßE IN BYTES }
BEGIN
FILEREC(F).RECSIZE := 1;
{$I-}
FSIZE := FILESIZE(F);
FILEERR := IORESULT;
{$I+}
END;
FUNCTION FPOS (VAR F:FILE):LONGINT; { FILEPOSITION }
BEGIN
FILEREC(F).RECSIZE := 1;
{$I-}
FPOS := FILEPOS(F);
FILEERR := IORESULT;
{$I+}
END;
PROCEDURE FSEEK (VAR F:FILE;P:LONGINT); { FILEPOINTER POSITIONIEREN }
BEGIN
FILEREC(F).RECSIZE := 1;
{$I-}
SEEK(F,P);
FILEERR := IORESULT;
{$I+}
END;
PROCEDURE FCLOSE(VAR F:FILE); { CLOSE WENN OFFEN }
BEGIN
{$I-}
IF (FILEREC(F).MODE = $D7B1) OR
(FILEREC(F).MODE = $D7B2) OR
(FILEREC(F).MODE = $D7B3)
THEN CLOSE(F);
{$I+}
FILEERR := IORESULT;
END;
PROCEDURE FGET(VAR F:FILE;P:POINTER;S:WORD); { GET ANZAHL BYTES AUS FILE }
BEGIN
FILEREC(F).RECSIZE := S;
{$I-}
BLOCKREAD(F,P^,1);
{$I+}
FILEERR := IORESULT;
END;
PROCEDURE FGETL(VAR F:FILE;VAR L:Longint); { PUT BYTE IN UNTYPISIERTES FILE }
BEGIN
FGET(F,@L,4);
END;
PROCEDURE FGETB(VAR F:FILE;VAR B:BYTE); { GET BYTE AUS UNTYPISIERTEM FILE }
BEGIN
FGET(F,@B,1);
END;
PROCEDURE FGETO(VAR F:FILE;VAR B:Boolean);
BEGIN
FGET(F,@B,1);
END;
PROCEDURE FGETC(VAR F:FILE;VAR C:CHAR); { GET CHAR AUS UNTYPISIERTEM FILE }
BEGIN
FGET(F,@C,1);
END;
PROCEDURE FGETW(VAR F:FILE;VAR W:WORD); { GET WORD AUS UNTYPISIERTEM FILE }
BEGIN
FGET(F,@W,2);
END;
PROCEDURE FGETI(VAR F:FILE;VAR I:INTEGER); { GET INTEGER AUS UNTYPISIERTEM FILE }
BEGIN
FGET(F,@I,2);
END;
PROCEDURE FGETH(VAR F:FILE;VAR W:WORD); { GET WORD HILO- NOTATION }
BEGIN
FGET(F,@W,2);
W := SWAP(W);
END;
PROCEDURE FGETR(VAR F:FILE;VAR R:REAL); { GET REAL AUS UNTYPISIERTEM FILE }
BEGIN
FGET(F,@R,6);
END;
PROCEDURE FGETP(VAR F:FILE;VAR P:POINTER); { GET POINTER AUS UNTYPISIERTEM FILE }
BEGIN
FGET(F,@P,8);
END;
PROCEDURE FGETS(VAR F:FILE;VAR S:STRING); { GET STRING AUS UNTYPISIERTEM FILE }
BEGIN
FGET(F,@S[0],1);
FGET(F,@S[1],ORD(S[0]));
IF EOF(F) THEN S := #0;
END;
PROCEDURE FGETLN(VAR F:FILE;VAR S:STRING); { GET LINE AUS UNTYPISIERTEM FILE }
VAR I : BYTE;
BEGIN
I := 0;
S := #0;
WHILE (NOT EOF(F)) AND (S[I] <> ^J) DO BEGIN
INC(I);
FGET(F,@S[I],1);
END;
IF (I > 0) AND (S[I] = ^J) THEN DEC(I);
IF (I > 0) AND (S[I] = ^M) THEN DEC(I);
S[0] := CHR(I);
END;
PROCEDURE FPUT(VAR F:FILE;P:POINTER;S:WORD);
BEGIN
FILEREC(F).RECSIZE := S;
{$I-}
BLOCKWRITE(F,P^,1);
{$I+}
FILEERR := IORESULT;
END;
PROCEDURE FPUTL(VAR F:FILE;L:Longint); { PUT BYTE IN UNTYPISIERTES FILE }
BEGIN
FPUT(F,@L,4);
END;
PROCEDURE FPUTB(VAR F:FILE;B:BYTE); { PUT BYTE IN UNTYPISIERTES FILE }
BEGIN
FPUT(F,@B,1);
END;
PROCEDURE FPUTo(VAR F:FILE;B:boolean);
BEGIN
FPUT(F,@B,1);
END;
PROCEDURE FPUTC(VAR F:FILE;C:CHAR); { PUT CHAR IN UNTYPISIERTES FILE }
BEGIN
FPUT(F,@C,1);
END;
PROCEDURE FPUTW(VAR F:FILE;W:WORD); { PUT WORD IN UNTYPISIERTES FILE }
BEGIN
FPUT(F,@W,2);
END;
PROCEDURE FPUTI(VAR F:FILE;I:INTEGER); { PUT INTEGER IN UNTYPISIERTES FILE }
BEGIN
FPUT(F,@I,2);
END;
PROCEDURE FPUTH(VAR F:FILE;W:WORD); { PUT WORD HILO- NOTATION }
BEGIN
W := SWAP(W);
FPUT(F,@W,2);
END;
PROCEDURE FPUTR(VAR F:FILE;R:REAL); { PUT REAL IN UNTYPISIERTES FILE }
BEGIN
FPUT(F,@R,6);
END;
PROCEDURE FPUTP(VAR F:FILE;P:POINTER); { PUT POINTER IN UNTYPISIERTES FILE }
BEGIN
FPUT(F,@P,8);
END;
PROCEDURE FPUTS(VAR F:FILE;S:STRING); { PUT STRING IN UNTYPISIERTES FILE }
BEGIN
FPUT(F,@S[0],SUCC(ORD(S[0])));
END;
BEGIN
END.