{$V-} (* Console IO redirection routines. Allows all console IO during program to be captured in disk file, with or without IO to console also. To start capture: IOP_OPEN ( FileName : AnyString ); Opens disk file of name FileName and redirects Console output to both the console and the disk file. If file already exists it is deleted and re-created. This routine turns on output to both the console and the disk file. To end capture: IOP_CLOSE; Closes the disk file and directs console output to console only. This call is essential to guarantee that the file buffer is flushed. To temporarily turn off capture while leaving disk file open: IOP_Wanted:=False; To turn capture back on for same disk file: IOP_Wanted:=True; To temporarily turn off output to console: CONIO_Wanted:=False; To turn console output back on: CONIO_Wanted:=True; Adjustable parameters: IOP_BufSize = 127; May be increased to any value of (N * 128) - 1 to decrease disk accesses. Required declarations: Type AnyString = string[255]; {$V-} string relaxation *) type anystring = string[255]; const iop_bufsize = 127; var iop_buf : array [0..iop_bufsize] of char; iop_x : integer; iop_file : file; iop_wanted, conio_wanted : boolean; { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - } procedure iop_outflush; var i : integer; begin if iop_x <> 0 then begin i := 0; repeat bdos($1A, addr(iop_buf) + i); {Set DMA} bdos($15 , addr(iop_file) + 12); {Write sequential} i := i + 128; until i >= iop_x; end; iop_x:=0; end; { - - - - - - - - - - - - - - - - - - - } procedure iop_outc( c :char); begin iop_buf[iop_x] := c; iop_x := iop_x + 1; if iop_x > iop_bufsize then iop_outflush; end; { - - - - - - - - - - - - - - - - - - - } procedure iopipe_out(c :char); begin if conio_wanted then bios(3,ord(c)); if iop_wanted then iop_outc(c); end; { - - - - - - - - - - - - - - - - - - - } procedure iop_close; begin iop_outc(^Z); iop_outflush; close(iop_file); iop_wanted:=false; end; { - - - - - - - - - - - - - - - - - - - } procedure iop_open( iop_fname : anystring ); begin assign(iop_file, iop_fname); rewrite(iop_file); iop_wanted := true; conoutptr := addr(iopipe_out); conio_wanted:=true; iop_x:=0; end; { = = = = = = = = = = = = = = = = = = = } { Example Code } var line : string[80]; i,j,k : integer; begin write('Name of log file: '); readln(line); iop_open(line); i := 0; repeat i := i + 1; write('Prompt ',i:2,': '); readln(line); until length(line) = 0; iop_close; end.