These functions provide general utility operations that do not fit neatly into a specific category. They are available throughout the Articles report script editor.
RaiseException
Raises a script exception with a custom message, immediately stopping report execution. Use this to enforce business rules or halt a report when a condition that should never occur is detected.
procedure RaiseException(Param: String)
| Parameter | Type | Description |
|---|---|---|
| Param | String | The error message to display when the exception is raised |
// Stop the report if a required parameter is missing
if IsNull([Param.StartDate]) then
RaiseException('Start Date is required to run this report.');
// Enforce a business rule
if [Orders.Total] < 0 then
RaiseException('Negative order total detected on Order #' +
VarToStr([Orders.OrderID]) + '. Report halted.');
// Gate access based on user confirmation
if not ShowPromptDialogConfirm('Restricted', 'Do you have authorisation to view payroll data?') then
RaiseException('Access denied.');
ShowMessage
Displays a simple message dialog with an OK button. Use this during development to quickly inspect a value. For production reports use ShowPromptDialog instead, which gives you control over the title and button text.
procedure ShowMessage(Msg: Variant)
| Parameter | Type | Description |
|---|---|---|
| Msg | Variant | The message or value to display |
// Quick value inspection during development
ShowMessage([Orders.Total]);
ShowMessage('Customer ID: ' + VarToStr([Customer.ID]));
// Check a calculated result before committing to a design
var tax := RoundTo2([Orders.Total] * 0.07);
ShowMessage('Tax = ' + FormatCurrencySafe(tax));
ValidDate
Returns True if a string can be successfully parsed as a date. Use this before calling StrToDate to avoid errors when a parameter or field value may not be a valid date.
ValidDate(cDate: String): Boolean
| Parameter | Type | Description |
|---|---|---|
| cDate | String | The string to validate as a date |
// Guard before converting a parameter string to a date
if ValidDate([Param.StartDate]) then
var d := StrToDate([Param.StartDate])
else
RaiseException('Start Date is not valid: ' + VarToStr([Param.StartDate]));
// Use as a safety check before date arithmetic
if ValidDate([Customer.LastOrderDate]) then
Result := IntToStr(DaysBetweenSafe(StrToDate([Customer.LastOrderDate]), Date)) + ' days ago'
else
Result := 'No orders on record';
// Validate before displaying
if ValidDate([Employee.TermDate]) then
Result := FormatDateSafe([Employee.TermDate], 'mm/dd/yyyy')
else
Result := 'Still active';
ValidFloat
Returns True if a string can be successfully converted to a floating point number. Use this before calling StrToFloat to avoid errors when a value may not be numeric.
ValidFloat(cFlt: String): Boolean
| Parameter | Type | Description |
|---|---|---|
| cFlt | String | The string to validate as a floating point number |
// Guard before a float conversion
if ValidFloat([Param.Rate]) then
Result := FormatCurrencySafe([Orders.Total] * StrToFloat([Param.Rate]))
else
RaiseException('Rate parameter is not a valid number.');
// Safe conversion with a fallback default
var rate: Double;
if ValidFloat([Param.TaxRate]) then
rate := StrToFloat([Param.TaxRate])
else
rate := 0.07; // default to 7%
Result := FormatCurrencySafe([Orders.Total] * rate);
ValidInt
Returns True if a string can be successfully converted to an integer. Use this before calling StrToInt to avoid errors when a value may not be a whole number.
ValidInt(cInt: String): Boolean
| Parameter | Type | Description |
|---|---|---|
| cInt | String | The string to validate as an integer |
// Guard before converting a parameter to an integer
if ValidInt([Param.MaxRecords]) then
var maxRecs := StrToInt([Param.MaxRecords])
else
RaiseException('Max Records must be a whole number.');
// Provide a safe default when the parameter might be missing
var pageSize: Integer;
if ValidInt([Param.PageSize]) then
pageSize := StrToInt([Param.PageSize])
else
pageSize := 25;
// Validate before use in a loop
if ValidInt([Param.RepeatCount]) and (StrToInt([Param.RepeatCount]) > 0) then
Result := RepeatText('-', StrToInt([Param.RepeatCount]));