Assert (Compiler Magic Function)
From RemObjects Software
This is a Oxygene Language Feature topic
Feel free to add your notes to this topic below.
Assertions produce a type of execution interrupt specially designed for development and debugging of applications. They are NOT designed to be used for live releases (see below).
Syntax:
method assert(boolean expression,'assert description');
If the boolean expression results in False, an assertion interrupt occurs and this shows you the location of the assert.
For example, consider the following code:
class method MainForm.Main; var x: Integer := 5; begin Assert(x < 5, 'assertion test'); end;
When the above code is ran, the following dialog is shown at runtime:
Assertion interrupts should not be confused with program exceptions - they are a different animal entirely. As the above screenshot shows, you have the option of ignoring the interrupt entirely or of going into debug mode.
Enabling Assertions
As stated above, you will want to suppress assertions when you deploy your application and this is controlled via project options. You can change if assertions are enabled in the project options by enabling or disabling 'Enable Asserts' there. In practice, you will normally stick to the defaults and build shipping versions using the Release configuration, where Enable Asserts is set to False.
See Also
Product: RemObjects Oxygene (formerly known as Chrome)
Current version: 3.0
Previous Versions: 'Joyride' (2.0), 'Floorshow' (1.5), 'Adrenochrome' (1.0)
Glossary — Keywords — Language Features — Platform Features — Samples — Articles — How To — Issues
Categories: Text | Oxygene | Language | Feature

