Share

RETURN statement

If a macro contains functions, the RETURN statement immediately exits the function. If the macro does not contain functions, the RETURN statement immediately terminates the current macro. This is useful if an error is detected and you do not want to continue with the remaining commands in the macro.

The basic control structure is:

EDIT TOOLPATH $tp.Name CALCULATE
IF NOT Computed {
    // terminate if toolpath did not calculate
    RETURN
}

To immediately exit from a function:

FUNCTION Calculate(STRING TpName) {

    IF NOT active(entity('toolpath',TpName).Tool.TipRadius) {
        // Error if toolpath does not use a tipradius tool
        PRINT "Toolpath does not have TipRadius tool"
        RETURN
    }

    EDIT TOOLPATH ; CALCULATE
}

FUNCTION Main() {

    FOREACH tp IN folder('Toolpath') {
        ACTIVATE TOOLPATH $tp.Name)
    }
}

Terminating macros

The command MACRO ABORT immediately terminates the current macro.

The command MACRO ABORT ALL terminates the all the macros that are currently running. If you call MACRO ABORT ALL from within a macro that has been called by another macro, then both macros are terminated.

Was this information helpful?