
Danaher Motion 06/2005 BASIC Moves Development Studio
M-SS-005-03 Rev E 35
An example of an OnError block, designed to stop motion in case of a
motion error:
OnError
Catch 3001 To 3999 ‘ Motion errors
System.Motion = 0
A1.Enable = 0
? VESExecute("System.Motion = 1")
A1. Enable = 1
Print "Caught a Motion error: " ThisTask.Prg.Error
Catch Else
Print "Caught a non-Motion error: " ThisTask.Prg.Error
End Onerror
The OnSystemError block is designed to trap and process both
synchronous and asynchronous errors in all tasks, as well as errors that
occur within the context of the system (For more details, see the Error
Handling section). Only one instance of OnSystemError may exist in
the system. The syntax for OnSystemError block is:
OnSystemError
{Catch Error_Number
{statements to be executed}}
{Catch Is <RelationalOperator> Error_Number
{statements to be executed}}
{Catch Error_Number1 To Error_Number2
{statements to be executed}}
{Catch Else
{statements to be executed}}
End OnSystemError
An example of an OnSystemError block, designed to monitor errors in
task Errors.Prg:
OnSystemError
Catch Is < 12000
Print “Caught a MC error: ” System.Error
‘ MC errors
KillTask Errors.Prg
Catch Is > 20000
Print “Caught a user error: ” System.Error
‘ User defined errors
KillTask Errors.Prg
End OnSystemError
2.2.13.2. NESTING
Program control commands can be nested. Nesting is when one program
control command (or block of commands) is within another. There is no
specified limit on the number of levels of nesting.
For example, the following program nests a WHILE…END WHILE sequence
within a FOR…NEXT sequence:
For I = 1 to 10
N=5
While N>0
N=N-1 'This command will be executed 50 times
End While
Next I
There is no specified limit on the number of levels of nesting. The Sample
Nesting Program in Appendix A shows numerous combinations of nesting.