Multiple Exitcodes

Added November 2010

The general A-Shell scheme for handling events relies on a single exitcode for each event. Usually this is sufficient, but with XTREE, a single click might logically be associated with more than one exitcode. (This complication is somewhat independent of the multi-tree scenario, but it is particularly acute here.) For example, consider a dialog with two XTREEs. The first tree has the focus, and the user is editing (changing) a cell (which is coded for validation). Then the user clicks on an item in the second tree. What is the appropriate exitcode? The one indicating the click on the inactive tree, or the one indicating validation required (-48) for the cell just exited? If the former, how does the app know to validate the edited cell? And if the latter, how does it know to activate the clicked-on tree?

To help simplify these kinds of issues, XTREE uses a few simple rules for determining which exitcode to return. First, whenever an XTREE session is terminated by a click on some other control (whether another XTREE or something else), the other control's click exitcode will take precedence. For example, if you click on a button or another XTREE whose click string is "VK_xF101", XTREE will exit with exitcode -101. In any other case, if multiple exitcodes are applicable (for example, cell validation and a custom exitcode from a PopupMenu), the cell validation exitcode (-48), if applicable, will take precedence. Finally, to receive information about multiple exitcodes, you may specify the xinfo parameter, which will be returned with a list of exitcodes. For example, in the case of a PopupMenu exitcode that interrupts a cell editing operation, the main exitcode parameter will contain -48, but xinfo may contain 0,-48,-200. The leading "0," indicates the nature of the information in the xinfo string, in this case, a list of exitcodes. And the -48,-200 indicates that both -48 (cell validation) and -200 (from the hypothetical PopupMenu choice) are applicable. (The first exitcode in the list may duplicate the value in the main exitcode parameter.)

A sophisticated application could then respond to both, i.e. validating the cell editing operation, and responding to the menu event associated with -200.