home *** CD-ROM | disk | FTP | other *** search
- {$I-}
- program testerr;
- uses dos, crt, printer, errtrp;
- var
- regs:registers;
- fil:file;
- Pchar:string;
- begin
- (*COMMENT OUT THE FUNCTIONS NOT BEING TESTED*)
- if mem[$0000:$0449]<>7 then ScrSeg:=$B800 else ScrSeg:=$B000;
- (* USING THE CRITICAL ERROR HANDLER PROCEDURE CRITERR *)
-
- (* remove disc from A: drive to test this *)
- (******************************************)
-
- write('trying to write to drive a: ');
-
- assign(fil, 'A:filename.ext');
- rewrite(fil);
-
- (* disable the printer to test these routines *)
- (*********************************************)
-
- writeln('trying to print with DOS write handle');
-
- repeat
- regs.ah:=2; { This code will detect off line }
- regs.dx:=0; { errors. The critical error trap}
- intr($17,regs); { will only trap if the printer is}
- if ((regs.ah and 8)=8) then {turned off.}
- begin
- writeln('Printer Error');
- halt;
- end
- else
- begin
- PChar:='this is the line';{This technique uses DOS handles for I/O}
- regs.ax:=$4000; {DOS write to handle }
- regs.bx:=4; {Use predefined printer handle #4 }
- regs.cx:=16; {Number of bytes to send (1 here) }
- regs.ds:=seg(PChar); {Segment of string to send }
- regs.dx:=ofs(PChar); {Offset of first character }
- MSDos(regs); {Make the function call... }
- end;
- until (keypressed or (ERRORRETRY=false));
- (*
- writeln('trying to print with lst');
- repeat
- regs.ah:=2;
- regs.dx:=0;
- intr($17,regs);
- if ((regs.ah and 8)=8) then
- begin
- writeln('Printer Error');
- halt;
- end
- else
- write(lst,'this is the line');
- until (keypressed or (ERRORRETRY=false));
-
-
- SetIntVec($24,SaveInt24);
- *)
- (* USING THE ERRTRAP PROCEDURE *)
- (*
- repeat
- assign(fil,'A:filename.ext');
- rewrite(fil);
- iocode:=ioresult;
- if IOCode<>0 then ErrTrap(IOCode);
- until ERRORRETRY=false;
-
- repeat
- write(lst,#13);
- iocode:=IOresult;
- if IOCode<>0 then ErrTrap(IOCode);
- until ERRORRETRY=false;
-
- repeat
- PChar:=#13;
- regs.ax:=$4000;
- regs.bx:=4;
- regs.cx:=1;
- regs.ds:=seg(PChar);
- regs.dx:=ofs(PChar);
- MSDos(regs);
- iocode:=IOresult;
- if IOCode<>0 then ErrTrap(IOCode);
- until ERRORRETRY=false;
- *)
-
- end.