// function.inc this library contains the functions for // manipulating functions. In particular, the conditional // execution routine lives in here type FUNCTION is string ; boolean CallFunctionIfExists( FUNCTION funcName ) { boolean bExecutedFunction ; do { @(funcName) () ; bExecutedFunction = True ; } except { // make sure that the exception is a function undefined // error - ConfirmException will reraise the exception if // there was some other problem. ConfirmException ( E_UNDEFINED ) ; // If we got this far, the only possible problem is that // this function did exist, but called something undefined. // So we need to make certain that funcName was the // missing function. // This is fairly easy to check - if funcName is undefined, // the exception must have been raised here. So all we need // to do is check the ExceptCalls() function, and verify that the // sFunction of the first call in the list matches this function. // Note that this does not get us into trouble in recursion - // the deepest call will catch and clear the exception, and the // others will ignore the possible problem. if ( ExceptCalls()[1].sFunction != "CallFunctionIfExists" ) reraise ; // Ok, if we have gotten this far, it must be that funcName // isn't defined. So report that the function was not executed bExecutedFunction = False ; } return ( bExecutedFunction ) ; }