Hi,
local XAxisSelectSwitchInput = mc.ISIG_INPUT4
That is not illegal but it does not gain you anything. mc.ISIG_INPUT4 is just a number, I think in this case the number is 3. Its called an ENUM. It means that you do not have
to remember that Machs #4 input has the numeric equivalent of three.
What you really want to do is have the handles assigned to a variable. This is problematic. Lua is a self-memory manged language. When a variable goes out of scope then it will
be 'Garbage Collected'. If you wish it to stay permanent then you have to use a global variable....but that means that Lua has to stop and resolve the address of the variable each and every time
its required.....poor programming.
A handle is effectively a memory address of the variable concerned. What happens when the whole Lua chunk goes out of scope? The variable gets garbage collected. When that chunk is read back into the
CPU when its required some time later that variable will be assigned anew....with a new address, aka handle. Lua makes use of stacks, and these stacks contain data variables that are in use at the moment,
but these stacks can and do shift around. So if you had a global variable that pointed to a specific memory address you're going to have trouble because that memory address is not the variable that you thought
it was....it may be another variable or piece of instruction code altogether and really screw things up.
I make it a habit to use a variable only if its handle is calculated/resolved WITHIN the same scope. I'm not sure that is strictly necessary....but on the other hand I know it works. I would say that having
handles all over the place is the price you pay for having dynamically allocated memory and autonomous garbage collection.
Craig