home *** CD-ROM | disk | FTP | other *** search
/ Delphi Programming Unleashed / Delphi_Programming_Unleashed_SAMS_Publishing_1995.iso / misc / excptexp / excepts / except1.dpr next >
Encoding:
Text File  |  1995-03-21  |  1.1 KB  |  35 lines

  1. program Except1;
  2.  
  3. { Program copyright (c) 1995 by Charles Calvert }
  4. { Project Name: EXCEPTS }
  5.  
  6. { This program shows that you can raise a Delphi exception
  7.   even though no error occured. The point is that exceptions
  8.   are just a device for reporting and handling errors, they
  9.   are not necessarily associated with the errors themselves.
  10.   In a DOS app, if you called WriteLn to tell the user that
  11.   an error occurred, there is no necessary connection between
  12.   WriteLn and the error. WriteLn just a function you are using
  13.   to report the error. The same is true with exceptions. You
  14.   could use them for some totally different purpose having
  15.   nothing to do with error handling, they just happen to
  16.   be a good means of reporting errors. In fact, they were
  17.   designed specifically, and more or less exclusively, for
  18.   that purpose. But you could use them for some other purpose
  19.   if you wanted. }
  20.  
  21. uses
  22.   SysUtils,
  23.   WinCRT,
  24.   WinProcs;
  25.  
  26. var
  27.   b: Boolean;
  28.  
  29. begin
  30.   b:= False;
  31.   WriteLn('hi');
  32.   if not b then
  33.     raise EOutOfMemory.Create('This is a test!');
  34. end.
  35.