In french: dbgAssertion
Used to find out and signal the possible errors via an assertive programming. dbgAssert
is used in a code where a possible error may occur. A window signals the problem if an error occurs.
This mode is used by default in test mode and it can be enabled at runtime by dbgEnableAssert
// The procedure named FindCustomer(Number) is used to find the specified customer
HReadSeekFirst(Customer, Number, Number)
dbgAssert(HFound, "Customer not found")
// SoughtValue was passed as parameter, it should exist in the data file.
// Position on the record
HReadSeekFirst(FileName, ItemName, SoughtValue)
// Check whether a record was found
// (in all cases, "standard" or "debug" mode)
IF HFound(FileName) = False THEN
// In "debug" mode, display a message to indicate that a problem occurred
dbgAssert(False, StringBuild("The %1 record of" + ...
"FileName was not found", SoughtValue))
// Manage this case in the code by creating a record if it was not found
FileName.ItemName = SoughtValue
dbgAssert(<Condition to check> [, <Comment>])
<Condition to check>: Character string
Condition whose test must be run. This condition can be a WLanguage function, a local or global procedure, an expression, ...
<Comment>: Optional character string
Text that will be displayed (in a window) if the condition is not checked.
- In test mode, the management of assertions is enabled by default.
- At runtime, the management of assertions is disabled by default. dbgAssert is not run. The WLanguage function specified in parameter will not be run.
- There is no need to use InTestMode when the management of assertions is enabled. This function was commonly used to monitor a specific operating mode that can now be done with dbgAssert.
- The messages of dbgAssert will be written into the ADB log (at "Assert" level). For more details, see Managing ADB logs.
This page is also available for…