SET ASSERT ENABLED
SET ASSERT ENABLED ( assertions {; *} )
Parameter | Type | Description | |
---|---|---|---|
assertions | Boolean | → | True = enable assertions False = disable assertions |
* | Operator | → | If omitted = command applies to all the processes (existing or created subsequently) If passed= command applies to current process only |
Description
The SET ASSERT ENABLED command can be used to disable or re-enable any assertions inserted into the 4D code of the application. For more information about assertions, please refer to the description of the ASSERT command.
By default, assertions added in the program are enabled in interpreted and compiled mode. This command is useful when you want to disable them since their evaluation can sometimes be costly in terms of execution time and you may also want them to be hidden from the final user of the application. Typically, the SET ASSERT ENABLED command could be used in the in order to enable or disable assertions according to whether the application is in "Test" mode or in "Production" mode.
By default, the SET ASSERT ENABLED command affects all the processes of the application. To restrict the effect of the command to the current process only, you can pass the * parameter.
Please note that when assertions are disabled, expressions passed to ASSERT commands are no longer evaluated. The lines of code that call this command no longer have any effect on the operation of the application, neither in terms of behavior, nor in terms of performance.
Example
Disabling assertions:
SET ASSERT ENABLED(False)
ASSERT(TestMethod) // TestMethod will not be called since assertions are disabled
See also
ASSERT
Asserted
Get assert enabled
Properties
Command number | 1131 |
Thread safe | ✓ |