One issue that may bite you is in fact that you're manipulating the Variables that you have set in the Main Program, in the various Subprograms. The Variables you're using are Common Variables, meaning that all programs that use these Variables are subject to the change to the variable made in another program. The change of #150 in the following #150=[#150-#106], for example, will be seen by all programs using #150.
One of the first rules of Software Programming and Macro Programming is a form of Software Programming, is that you only use Global Variables where they are absolutely necessary. If a Local Variable can be used, then use it.
I'm not sure of the case with later model Yasnac Controls, but older models, Common Variables would have to be used to register the values of the Variables; Local Variables can't be used in the Main Program. But with Haas, Fanuc and many other controls, that isn't the case. Because of the number of Variables you're defining in the Main Program, there aren't enough Local Variables, therefore, if you deem that all the Variables are required, then Common Variables will have to be used. However, you need to get into the GOOD habit of using Local Variables in your Subprograms. Any changes to Local Variables in any Sub or Macro Program (there is a difference between the two types of programs), won't affect the same Local Variables in any other Sub or Macro Program. The only time you may want to change the value of a Common Variable is when another Sub or Macro program (more for a Subprogram than a Macro Program) may be being called from within a Sub or Macro Program. Even in this situation, rather than Call a Subprogram, the values of a Local Variable used in one Subprogram or Macro Program can be passed as an argument to another Macro Program (not to a Subprogram)
Regards,
Bill