Hi TP,
no the #2=54 is only set at the end of the sub.
The G-code work as it should.
there is an issue in mach I'm sure.
You can test this as follows: load the code. input different values for the Fixtures e.g. for G54 X axis -40 for G55 X axis -60 and so on.
it is not necessary that the computer is connected to a machine to see what i mean. so it should be safe to test.
Set the LookAhead in general config to 20 lines ( default ) open the G code variable monitor in Operator section
start the code and watch the G Code Line ( the line that shows what G code is actual active ) look for the fixtures ( G54, G55 ....)
You will see the first part cutting with fixture G55 what is not correct.
now set the LookAhead in general config to 1 line
You will see then the first part cutting with fixture G54 what is correct.
if you look closely, you will realize that mach " Looks Ahead" in this case 20 lines calculate the values of the variables and set it.
In other words how can variable #2 set to 55 before the line is executed?
sorry, for the bad English

alex
