void = RaiseError(sErrorMessage, bAbortScript)
Use the RaiseError macro function to generate your own error messages during the execution of a macro.
This void function takes 2 parameters :
sMessage |
This is the text that will appear in the error message, whether it is simply a run-time message, or it causes the script to abort. |
bAbortScript |
If the value of bAbortScript is set to false then the failure of this assertion will simply abort the current macro and generate a run-time message which will be displayed in the messages window during diary generation. If the value of bAbortScript is set to true then the failure of this assertion will abort the current script and display a modal message with the context of the error (see example below). |
The RaiseError function is useful when you know that the macro execution reaching a certain position is definitely an error (no need to check if a condition is true as in the case of the Assert function).
switch nWeekdayNumber
case 1..5
// do weekday stuff
case 6..7
// do weekend stuff
else
RaiseError('nWeekdayNumber is not in range of 1-7', true)
endswitch
Examples
bAbortScript = false
The following call to RaiseError with bAbortScript being false,
RaiseError('nWeekdayNumber is not in range of 1-7', false)
would then add the following messages to the diary generation messages dialog, without interrupting the script execution.
bAbortScript = true
The following call to RaiseError with bAbortScript being true,
Assert(nInputValue in [1..7], 'Weekday is not in range of 1-7', true)
would then immediately display the following dialog, with detailed information about the context of the message, and then abort script execution.
Alternatives
If you only want to verify that a unique basic assumption is true, then an alternative is to use the Assert function, instead, or if you want a run-time message to be generated, without causing any error condition, you may want to use the LogMessage function.
Topic 174290, last updated on 19-Apr-2020