Using COLLAPSE in MCK projects.

Installing COLLAPSE. Select a directory for COLLAPSE, e.g. C:\KOL\Prj\COLLAPSE and unpack there files from the archive (below if the path is starting from COLLAPSE, I mean this directory).

P-code is generated in MCK for all forms automatically (yet before installing the COLLAPSE). In case when design-time components are using which yet no have P-code generation implemented, P-code is not generated for entire form. It is possible to detect this situation visually:

To provide generated P-code to work, it is necessary to do following steps:

It is now possible to ensure that inc-files are containing P-code, and call P-compiler. After it successful funishing all project units containing P-code are modified and for P-code compiled assembler code is generated (it contains only data directives DB, DW and DD and is starting from one of bytes $E4..$E7). Now run compiled project and find that it is working exactly as earlier at least no changes should be detected visually.(If there are any differences, this mean an error in code generation, so write me or to the author of the MCK-component affected to solve a problem). If it is necessary to run P-debuger, add a conditional symbol COLLAPSE_DEBUG (path to the debugger must be in the file PCompiler.cfg at the key /D).

While compiling assembler code created by the Pcompiler, it is possible that Delphi find following errors:

Now you can compare size of the executable, with option Pcode. For small projects P-code will not reduce it more since first about 500-600 bytes are added and only after this code become reducing. Effect become evident only for large enough projects having big form initialization procedures (i.e. when amount of MCK-components is enough), because P-code is 2-3 times more compact then original machine code compiled from Pascal. It is possible that in result of additional compressing the executable with some compressors (such as UPX) effect become even more evident since P-code does not contain relative offsets in it and can be compressed at least not worst then the original machine code.

If the project contains other long (and very long) initialization procedures, e.g. in OnShow event, it is also possible to P-code it manually and P-compile. See correspondent manual. If you have KOL component with MCK mirror and you want make it compatible with P-code like standard MCK component do, see correspondent instruction too.

Additinal feature: if to uncomment the line {$DEFINE NOEXCEPTONEXIT} in the Collapse.pas, then in case of any exception when the application is finishing it will be silently suppressed and the application halt without any further messages. You should in your code assign TRUE to a variable AppletTerminating (defined in the Collapse.pas) as soon as terinating of the execution is starting (otherwise only AppletTerminated is checked but this can be not enough in some cases).
    I know that this not good practice but there are some cases when exception on exit of the application can not be easily solved. E.g. if some third-party libraries are used and errors are deep in their code or your application works with data which can be partially damaged (images, sounds, etc.).


Vladimir Kladov, 3-Dec-2005

Last update: 21-Jan-2006