Manually set the value of the @error macro.
SetError ( code [, extended [, return value]] )
| code | The required value (integer) to set the @error macro to. |
| extended | [optional] The optional value (integer) to set the @extended macro to. This sets the same macro as the SetExtended() function. |
| return value | [optional] Override the default return value and return this parameter. |
Local $result = myDiv(5, 0)
If @error Then
MsgBox(4096, "Error", "Division by Zero")
Else
MsgBox(4096, "Result", $result)
EndIf
Exit
Func myDiv($dividend, $divisor)
If $dividend = 0 And $divisor = 0 Then
SetError(2) ;indeterminate form 0/0
ElseIf $divisor = 0 Then
SetError(1) ;plain division by zero
EndIf
Return $dividend / $divisor
EndFunc ;==>myDiv