home *** CD-ROM | disk | FTP | other *** search
- (* ------------------------------------------------------ *)
- (* REDIROUT.PAS *)
- (* Umleitung der Standard-Ausgabe *)
- (* (c) 1993 te-wi Verlag, München *)
- (* ------------------------------------------------------ *)
- UNIT RedirOut;
-
- {$A+,B-,D+,E+,F-,G-,I+,L+,N-,O-,P-,Q+,R+,S+,T-,V+,X+,Y+}
- {$M 16384,0,655360}
-
- INTERFACE
-
- CONST
- stdin : WORD = 0;
- stdout : WORD = 1;
- stderr : WORD = 2;
-
- RedFile : STRING = 'STDOUT.RED' + #0;
-
- VAR
- oldin : WORD;
- oldout : WORD;
- olderr : WORD;
- Err : WORD;
-
- FUNCTION RedOut : WORD;
- FUNCTION RedBack : WORD;
-
- IMPLEMENTATION
-
- FUNCTION RedOut : WORD;
- BEGIN
- ASM
- MOV BX, stdout
- MOV AH, 45h
- INT 21h (* duplicate stdout *)
- JC @Error (* failed *)
-
- MOV oldout, AX (* save stdout *)
-
- MOV CX, 0 (* normal attribute *)
- MOV DX, OFFSET redfile + 1
- MOV AH, 3Ch
- INT 21h
- JC @Error (* failed *)
-
- MOV BX, AX (* redirect stdout hdle to *)
- MOV CX, stdout (* track the new file hdle *)
- MOV AH, 46h
- INT 21h
- JC @Error (* failed *)
-
- MOV Err, 0
- JMP @ok
- @Error:
- MOV Err, AX (* Error code *)
- @Ok:
- END;
- END;
-
- FUNCTION RedBack : WORD;
- BEGIN
- ASM
- MOV BX, oldout (* restore original handle *)
- MOV CX, stdout
- MOV AH, 46h
- INT 21h
- JC @Error2 (* failed *)
-
- MOV BX, oldout (* close dup'd handle *)
- MOV AH, 3Eh
- INT 21h
- JC @Error2 (* failed *)
-
- MOV Err, 0
- JMP @ok2
- @Error2:
- MOV Err, AX
- @Ok2:
- END;
- END;
-
- BEGIN
- END.
- (* ------------------------------------------------------ *)
- (* Ende von REDIROUT.PAS *)
-
-