File MIES_Utilities_ProgramFlow.ipf

utility functions for program flow

Functions

variable AssertOnAndClearRTError()

Helper function to ensure that there is no pending RTE before entering a critical section. If there is a pending RTE then a BUG message is output (which is a CI error).

Not catching any pending RTE would clear this condition silently and valid errors would be suppressed. This is dangerous in regards of data consistency.

Not clearing the RTE before calling AbortOnRTE will always trigger the RTE no matter what you do in that line. Any call to GetRTErrMessage() must be done prior to clearing the runtime error in the catch block.

Usage:

AssertOnAndClearRTError()
  try
    CriticalFunc(); AbortOnRTE
  catch
    msg = GetRTErrMessage()
    err = ClearRTError()
  endtry

UTF_NOINSTRUMENTATION

variable ClearRTError()

Helper function to unconditionally clear a RTE condition It is generally strongly recommended to use.

UTF_NOINSTRUMENTATION

See also

AssertOnAndClearRTError before critical code sections. For detailed description of the implications

variable IsFunctionCalledRecursively()

Return true if the calling function is called recursively, i.e. it is present multiple times in the call stack.

variable DoAbortNow(string msg)

Wrapper function for Abort which honours our interactive mode setting.

string GetStackTrace(string prefix = defaultValue)

Return a nicely formatted multiline stacktrace.

variable ASSERT(variable var, string errorMsg, variable extendedOutput = defaultValue)

Low overhead function to check assertions.

Example usage:

ControlInfo/W = $device popup_MoreSettings_DeviceType
ASSERT(V_flag > 0, "Non-existing control or window")
do something with S_value

UTF_NOINSTRUMENTATION

Parameters:
  • var – if zero an error message is printed into the history and procedure execution is aborted, nothing is done otherwise. If the debugger is enabled, it also steps into it.

  • errorMsg – error message to output in failure case

  • extendedOutput – [optional, defaults to true] Output additional information on failure

variable ASSERT_TS(variable var, string errorMsg, variable extendedOutput = defaultValue)

Low overhead function to check assertions (threadsafe variant)

Example usage:

ASSERT_TS(DataFolderExistsDFR(dfr), "dfr does not exist")
do something with dfr

Unlike ASSERT() this function does not jump into the debugger (Igor Pro limitation).

UTF_NOINSTRUMENTATION

Parameters:
  • var – if zero an error message is printed into the history and procedure execution is aborted, nothing is done otherwise.

  • errorMsg – error message to output in failure case

  • extendedOutput – [optional, defaults to true] Output additional information on failure

variable AlreadyCalledOnce(string name)

Return 1 if the function was already called with that argument, and 0 otherwise As named use or create a constant in.

See also

CalledOnceNames