initial commit
[rofl0r-KOL.git] / readme_kol_err.txt
blobf7f17facc835cb8ce2e29798748c8be087e4cb40
1 STRUCTURAL EXCEPTION HANDLING and MATHIMATICAL ROUTINES\r
2 ADAPTATION (with COMPLEX MATHEMATICS SUPLEMENTS) \r
3 for KEY OBJECTS LIBRARY\r
4 -----------------------------------------------------\r
5 version 7.0.181, 1-Aug-2003\r
6 Copyright (C) 2001-2003, Vladimir Kladov.\r
7 \r
8 \r
9 This archive contains three additional units for the Key Objects Library:\r
10   ERR.PAS      - replaces SysUtils.pas in part of exceptions handling;\r
11   MMX.PAS      - small utility function to detect MMX capabilities of CPU;\r
12   KOLMATH.PAS  - replaces standard Delphi MATH.PAS with minimal changes.\r
13   CPLXMATH.PAS - a unit to work with complex numbers.\r
15 KOL is intended to allow to develop small but power Win32 GUI applications using great Delphi IDE envirnment. With this archive, the lack of exceptions handling in KOL is filling up. Using of ERR.PAS increases a size of executable about 6K bytes. But this allow to create "robust" applications, saving its size therefore small (at least, much smaller than using ANY OTHER Win32 development tools, which support Structural Exception Handling).\r
17 To use ERR.PAS, just include a reference to it in uses clause of any unit of the project, or in uses clause of the dpr file.\r
19 The main difference of exception handling suggested in ERR.PAS, is that the only single exception class (named Exception) should be used. Do not derive your own exception classes from it, but always create instances of Exception class. Instead of comparing class of the exception object with certain class type using 'is' operator, just compare Code property of the exception with certain predefined constant. Since this, usage of 'except on' construction is changed a bit:\r
21 instead of writing\r
22 ====== CUT BEGIN ======\r
23 try ...\r
24 except\r
25   on EIntOverflow  do HandleOverflow;\r
26   on EDivideByZero do HandleZeroDivide;\r
27   else HandleOther;\r
28 end;\r
29 ====== CUT END ======\r
31 write now following:\r
32 ====== CUT BEGIN ======\r
33 try ...\r
34 except on E: Exception do\r
35   case E.Code of\r
36   e_IntOverflow: HandleOverflow;\r
37   e_DivBy0:      HandleZeroDivide;\r
38   else           HandleOther;\r
39   end;\r
40 end;\r
41 ====== CUT END ======\r
43 And, to raise your own exception, write one of following:\r
44 ====== CUT BEGIN ======\r
45   ... raise Exception.Create( e_Custom, 'This is my exception' );\r
46   ... raise Exception.CreateCustom( 12345, 'This my exception 12345' );\r
47   ... raise Exception.CreateCustomFmt( 67890, 'Custom error %d', [ MyBadVar ] );\r
48 ====== CUT END ======\r
50 KOLMATH.PAS is provided as a replacement of standard MATH.PAS unit. The difference is mainly that it uses ERR.PAS instead of SysUtils.pas. Another difference is that all references to Abs function are replaced to EAbs. There are no other differences, so You can use Delphi help system to get know about functions from MATH.PAS. CPLXMATH is additional unit to work with complex numbers. It can be used separately from KOL. To use it in non-visual KOL Delphi projects (KOL without MCK), define a symbol KOL in project options. This is not necessary for MCK projects.\r
52 In this version, changes made, which allow to use ON EXCEPTION handling not only for exceptions, raised in our custom code, but all others too (as defined above).\r
53 Also, mmx.pas changed (because command CPUID changes EBX register).\r
55 ------------------------------------------------------------------------\r
56 http://bonanzas.rinet.ru\r
57 mailto: bonanzas@online.sinor.ru\r