home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 15 / CDACTUAL15.iso / cdactual / program / pascal / IOFUNC.ZIP / VIOERR.TST < prev    next >
Encoding:
Text File  |  1986-04-12  |  3.1 KB  |  84 lines

  1. {           ╔═══╦══════════════════════════════════════════════╦═══╗
  2.             ║   ║         Pascal Library by Scott Wade         ║   ║
  3.             ║   ║           715 FM 1959      Apt 310           ║   ║
  4.             ║   ║           Houston, TX 77034                  ║   ║
  5.      ┌──────╨───╨──────────────────────────────────────────────╨───╨──────┐
  6.      │  This  group of routines is contributed to public domain,  and no  │
  7.      │  one can possibly get any commercial value out of them since they  │
  8.      │  must be used in other programs. I require that if these are used  │
  9.      │  as is in  any  program,  that this banner remain with the source  │
  10.      │  code of the program.  I would appreciate any comments or sugges-  │
  11.      │  tions on improvements, & am curious to hear how these are used.   │
  12.      │  You can leave a message for me on these BBS's:                    │
  13.      │          Ziggy's  821-1391         ScoreBoard  583-7848            │
  14.      │          TBL-COMM 661-9040         Test-Mode   660-9252            │
  15.      └────────────────────────────────────────────────────────────────────┘
  16.  v1.1 vIOErr.TST test the IOErr message generator library.
  17.  Sep/27/85 added v1.1 : documentation cleaned up some.}
  18.  
  19. Type
  20.    Buffer       =  string[ 255 ];
  21.  
  22. const
  23.   IOErrVal             : Integer = 0;
  24.   IOErr                : Boolean = False;
  25.   TrapErr              : Boolean = False;
  26.  
  27. var
  28.   InFile               : Text;
  29.   IOErrMsg             : Buffer ;
  30.   DummyStr             : Buffer ;
  31.  
  32. {$I vIOErr.LIB}
  33.  
  34. procedure PutLineNum(LineNum : Integer);
  35. {   This routine tells you which line is being executed, so that you can
  36.     see which statement is causing which error.
  37. }
  38. begin
  39.    GotoXY(1,10);
  40.    ClrEol; writeln('Test of vIOErr.LIB v1.1  Press a key to continue. ');
  41.    ClrEol; Writeln('Executing line #',LineNum);
  42.    ClrEol; writeln('MSG> ',IOErrMsg,'<');
  43.    ClrEol; writeln('IOErr is ',IOErr);
  44.    ClrEol; writeln('IOErrVal is ',IOErrVal:3);
  45.    IOErrMsg := '';
  46. end{ PutLineNum };
  47.  
  48. begin{ MAIN }
  49.    IOErr := False ;
  50.    IOErrVal := 0;
  51.    IOErrMsg := '';
  52.  
  53. {$I-}
  54.    { assign a dummy file..this should work ok. }
  55.    Assign(InFile,'dummy');
  56.    vIOerr( IOErrMsg, IOErrVal, IOErr );
  57.    PutLineNum(1);   Repeat Until Keypressed;
  58.  
  59.    { write to the file..this should also work ok }
  60.    Rewrite(InFile);
  61.    vIOerr( IOErrMsg, IOErrVal, IOErr );
  62.    PutLineNum(2);   Repeat Until Keypressed;
  63.  
  64.    { Attempt to read from file assigned for write..this should error }
  65.    PutLineNum(3); Read(Infile,DummyStr);
  66.    vIOerr( IOErrMsg, IOErrVal, IOErr );
  67.    PutLineNum(3); Repeat Until Keypressed;
  68.  
  69.    { close file..this should work ok }
  70.    Close(Infile);
  71.    vIOerr( IOErrMsg, IOErrVal, IOErr );
  72.    PutLineNum(4);
  73.  
  74.    { attempt to read from a file that isnt open...this should error }
  75.    PutLineNum(5); Read(Infile,DummyStr);
  76.    vIOerr( IOErrMsg, IOErrVal, IOErr );
  77.    { test of the function that prints the error message for you. }
  78.    Traperr := vTrueIferr( IOErrVal, IOErrMsg );
  79.    If TrapErr then writeln( 'Error Trapped.');
  80.  
  81. {$I+}
  82. end.{ vIOErr.TST
  83. *****************************************************************************}
  84.