Escape Code

Control Block

Description

The Escape Code block is used within the "Recover" Block List of a Try Recover block to provide information about an exception. Program execution lands in a "Recover" block list because of an error. The Escape Code expression provides the error number indicating the type of error. The Escape Code can be compared against Escape Code Constants to identify the type of error. Generally Recover block lists should conclude by reissuing the Escape Code if the error has not been handled. However if the procedure is a top-most task the recover block should handle the error itself in a manner consistent with the applicaiton. If the error is not handled by the application it will be shown by Snap2Motion's default exception handler.

Escapes

The Escape Code block does not produce any escapes.

Examples

Axis resources can be arranged and operated in groups or as individual axes. However an axis can't be used for two different purposes at the same time. Consider this situation where two motors are participating in a group called "XYTable" and performing a long 2 axis coordinated move:

While this group is in motion another task attempts to operate one of the component motors of that group with a separate move:

If the single axis Jog is performed while that same motor is already committed to a coordianted acitivity directed by the XYTable this error will occur:

This error means the axis is already busy and not available to respond to this Jog command. This error could be detected and, presuming that the Jog was more important than the XYTableMove, handled this way:

The Escape Code expression is used twice. If the Jog command produces an exception the program transitions to the "Recover" block. The Escape Code that was generated is compared to the Axis Is Busy Escape Code constant. If found to be that error the XYTable is commanded to stop and the Jog command reissued. Now that the motor has stopped and is no longer busy the Jog command succeeds. If the Escape Code is not the Axis is Busy Escape Code then the exception is reissued in the else section of the recover block list.

Consider this button click block list that is assigning a variable named "Part_Count" from a Count_Part_Editor.

If the value in the editor is not numeric a read exception occurs and the program moves to the recover block list. The Escape Code is compared to the constant Read Escape Code If it was a read escape code a prompter asks for the editor value to be checked. If the error was something else a prompter explains that the error is not being handled. A button click procedure has no procedure calling it. This is the top-most task so it is not helpful to reissue the exception. The only thing above this click procedure is the Snap2Motion environment which would show the developer explanation of the error. In this case it is better to manage how the error should be displayed for this particular application rather than use the default Snap2Motion handler.

Related Topics

Try Recover
Escape
Escape Code Constants