Hi,
you are confusing a macro and a button script. Try writing them a two distinctly different pieces of code.
Next thing is don't call it m22(). All your macros should be named m100() or higher, avoiding m162 and m163
as they are also used by Mach for Laser Operations.
Try saving this as your macro, note that I renamed it m220():
function m220()
local inst=mc.mcGetInstance()
local sigHandle=mc.mcSignalGetHandle(inst,mc.OSIG_OUTPUT2)
mc.mcSignalSetState(sigHandle,1)
end
if (mc.mcInEditor()==1) then
m220()
end
For the button script use this:
local inst=mc.mcGetInstance()
local sigHandle=mc.mcSignalGetHandle(inst,mc.OSIG_OUTPUT2)
mc.mcSignalSetState(sigHandle,1)
You could as Chas has suggested call the macro with the mcCntlMDIExecute() API. When you press the button
the GUI chunk is running. Its actionis to execeute a macro which is in a different chunk, ie Mach has to switch from
one chunk to another. It can and does this all the time, but in this case is unnecessary, just repeat the functional code
in the button script and it will be compiled and contained within the GUI chunk and have no need of a context switch
to execute.