home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / ERRTRP.ZIP / TESTERR.PAS < prev   
Encoding:
Pascal/Delphi Source File  |  1988-02-23  |  2.2 KB  |  92 lines

  1. {$I-}
  2. program testerr;
  3. uses dos, crt, printer, errtrp;
  4. var
  5. regs:registers;
  6. fil:file;
  7. Pchar:string;
  8. begin
  9. (*COMMENT OUT THE FUNCTIONS NOT BEING TESTED*)
  10. if mem[$0000:$0449]<>7 then ScrSeg:=$B800 else ScrSeg:=$B000;
  11. (*       USING THE CRITICAL ERROR HANDLER PROCEDURE CRITERR  *)
  12.  
  13. (* remove disc from A: drive to test this *)
  14. (******************************************)
  15.  
  16. write('trying to write to drive a: ');
  17.  
  18.   assign(fil, 'A:filename.ext');
  19.   rewrite(fil);
  20.  
  21. (* disable the printer to test these routines *)
  22. (*********************************************)
  23.  
  24. writeln('trying to print with DOS write handle');
  25.  
  26. repeat
  27. regs.ah:=2;                   { This code will detect off line }
  28. regs.dx:=0;                   { errors. The critical error trap}
  29. intr($17,regs);               { will only trap if the printer is}
  30. if ((regs.ah and 8)=8) then   {turned off.}
  31.   begin
  32.     writeln('Printer Error');
  33.     halt;
  34.   end
  35.   else
  36.   begin
  37. PChar:='this is the line';{This technique uses DOS handles for I/O}
  38. regs.ax:=$4000;           {DOS write to handle                    }
  39. regs.bx:=4;               {Use predefined printer handle #4       }
  40. regs.cx:=16;              {Number of bytes to send (1 here)       }
  41. regs.ds:=seg(PChar);      {Segment of string to send              }
  42. regs.dx:=ofs(PChar);      {Offset of first character              }
  43. MSDos(regs);              {Make the function call...              }
  44. end;
  45. until (keypressed or (ERRORRETRY=false));
  46. (*
  47. writeln('trying to print with lst');
  48. repeat
  49. regs.ah:=2;
  50. regs.dx:=0;
  51. intr($17,regs);
  52. if ((regs.ah and 8)=8) then
  53.   begin
  54.     writeln('Printer Error');
  55.     halt;
  56.   end
  57.   else
  58.   write(lst,'this is the line');
  59. until (keypressed or (ERRORRETRY=false));
  60.  
  61.  
  62. SetIntVec($24,SaveInt24);
  63. *)
  64. (*  USING THE ERRTRAP PROCEDURE *)
  65. (*
  66. repeat
  67. assign(fil,'A:filename.ext');
  68. rewrite(fil);
  69. iocode:=ioresult;
  70. if IOCode<>0 then ErrTrap(IOCode);
  71. until ERRORRETRY=false;
  72.  
  73. repeat
  74. write(lst,#13);
  75. iocode:=IOresult;
  76. if IOCode<>0 then ErrTrap(IOCode);
  77. until ERRORRETRY=false;
  78.  
  79. repeat
  80. PChar:=#13;
  81. regs.ax:=$4000;
  82. regs.bx:=4;
  83. regs.cx:=1;
  84. regs.ds:=seg(PChar);
  85. regs.dx:=ofs(PChar);
  86. MSDos(regs);
  87. iocode:=IOresult;
  88. if IOCode<>0 then ErrTrap(IOCode);
  89. until ERRORRETRY=false;
  90. *)
  91.  
  92. end.