Jelle,
What are you referring too as a variable?
The best thing to use is a register.
They can be seen and read from all parts of Mach4
Bill
This is only true if .......... there isn't already a signal constant (to be used in an api that can be seen from all) defined. If there isn't a constant creating a register is perfectly acceptable.
Getting the state of the OSIG_TOOL_CHANGE signal returns a 0.0 if the tool change is not running and 1.0 if it is.
local inst = mc.mcGetInstance()
local rc = nil
local hSig = nil
local state = nil
hSig, rc = mc.mcSignalGetHandle(inst, mc.OSIG_TOOL_CHANGE)
state, rc = mc.mcSignalGetState(hSig)
mc.mcCntlSetLastError(inst, tostring(state))
Test the above using the default Mill4 profile.
You can put the above code in a wizard. Name the wizard something like test.mcs.
Select the wizard form the list. See what you get in the status bar.
In a default profile, start the tool change (default tool change waits on user to click cycle start to finish). Be sure you call a tool that isn't the current tool because if the Current tool == Selected tool there is nothing to do. Select the wizard form the list. See what you get in the status bar.
Once the tool change is finished select the wizard form the list. See what you get in the status bar now.