spec

Software for Diffraction

2.3.13. - Cleanup Macros



On keyboard interrupts (and command and syntax errors), if macros named cleanup_once or cleanup_always have been defined, their definitions are read as input. Typical uses of the cleanup_once macro are to return motors to starting positions on an interrupted delta scan or to display counter contents if counting is interrupted.

After running the cleanup_once and/or cleanup_always macros, spec gives the standard prompt and waits for the next command from the keyboard. The cleanup_once macro is removed before the next main prompt is issued, whether or not it was triggered.

Definitions for these macros should be constructed using the cdef() (chained macro) function (described 2.4.4.1 in order to allow various clean-up actions to be added and removed during the flow of arbitrary statement blocks.

The legacy cleanup macros cleanup and cleanup1 remain supported. Like cleanup_always, the macros remain defined across the standard prompt. However, unlike cleanup_always, both cleanup and cleanup1 are deleted if they generate an error or the commands contained therein are interruped by ^C.