Machsupport Forum
Mach Discussion => VB and the development of wizards => Topic started by: atwoodr on February 28, 2014, 10:33:02 PM
-
Hi all, I have a program that cuts many different types of boxes. Each screen has a "cut" button that executes a set of commands that is unique to that page. However, at the bottom of each file of code in this "cut" button is a set of 10-15 Subroutines / functions that are exactly the same for each screen / box / button.
How do I extract these 10-15 functions into a separate .vb file that I can include or import in Mach3? The idea is that I don't have any duplicate code.
-
atwoodr,
I think what you are looking to use is the #expand command. It is only in the later (V3.43.19 or after) Mach3 I think.
To use, put your 10 to 15 subs into their own m1s file called whatever you name it.
at the bottom of your button code, you would insert the following:
#expand "c:\mach3\the path to your m1s file\filename.m1s" (the quotes around the path are required)
You can use this recursively and straight from a button.
ie, you can #expand a script into the button without your code being in the button, and then you can also have your script file contain an #expand in it to pull in different files that have code you want to reuse.
Good luck!
-
Thanks so much, this works great! Finally, no more duplicate code!