Hello Guest it is April 24, 2024, 11:22:57 AM

Author Topic: How do I Import or Include a "common" vb file?  (Read 3095 times)

0 Members and 1 Guest are viewing this topic.

How do I Import or Include a "common" vb file?
« 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.
Re: How do I Import or Include a "common" vb file?
« Reply #1 on: March 12, 2014, 09:01:55 PM »

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!

Re: How do I Import or Include a "common" vb file?
« Reply #2 on: March 15, 2014, 10:26:55 PM »
Thanks so much, this works great!  Finally, no more duplicate code!