Get state of IndependentModuleDev?

Do we have a consistent way to determine the state of IndependentModuleDev (0 or 1)? I would like to build one macro to toggle it on/off rather than two macros, one to turn on and one to turn off.

Great! Thanks.

Menu "Macros", dynamic
    MacrosMenuIMD(),/Q, toggle_IMD()
end

Function/S MacrosMenuIMD()
    string rtnstr = "Toggle IMD "
    string cmdq = "SetIgorOption independentmoduledev=?"
    Execute cmdq
    variable/G v_flag
    if (v_flag)
        rtnstr += "OFF"
    else
        rtnstr += "ON"
    endif
    killvariables/Z v_flag
    return rtnstr
end

Function toggle_IMD()
    string cmdq = "SetIgorOption independentmoduledev=?"
    string cmdt = "SetIgorOption independentmoduledev=!(v_flag)"
    Execute cmdq
    variable/G v_flag
    if (v_flag)
        print "Independent Module Development OFF"
    else
        print "Independent Module Development ON"  
    endif
    Execute cmdt
    killvariables/Z v_flag
    return 0
end

 

In reply to by jjweimer

An alternative using a menu checkmark:

menu "Macros", dynamic
    MacrosMenuIMD(), /Q, toggle_IMD()
end

function/S MacrosMenuIMD()
    string rtnstr = "IM development"
    string cmdq = "SetIgorOption IndependentModuleDev=?"
    Execute cmdq
    variable/G v_flag
    if (v_flag)
        rtnstr += "!" + num2char(18)
    endif
    KillVariables/Z v_flag
    return rtnstr
end

function toggle_IMD()
    string cmdq = "SetIgorOption IndependentModuleDev=?"
    string cmdt = "SetIgorOption IndependentModuleDev=!(v_flag)"
    Execute cmdq
    variable/G v_flag
    if (v_flag)
        Print "Independent Module Development OFF"
    else
        Print "Independent Module Development ON"
    endif
    Execute cmdt
    KillVariables/Z v_flag
    return 0
end