Machsupport Forum

Mach Discussion => VB and the development of wizards => Topic started by: rrc1962 on June 28, 2011, 11:38:58 PM

Title: Compiling Macro Script
Post by: rrc1962 on June 28, 2011, 11:38:58 PM
Can you compile a VB script?  It is actually a button script.  If yes, could someone point me in the right direction?

Thanks very much.
Title: Re: Compiling Macro Script
Post by: BR549 on June 29, 2011, 12:19:03 AM
Using the VB editor you have 2 options save as macro OR a compiled macro.

(;-) TP
Title: Re: Compiling Macro Script
Post by: Tony Bullard on June 29, 2011, 08:44:56 AM
I have searched the forums and Mach Customize Wiki for more info on compiled macros and this is the only thread with a reference to it. How would you use a compiled macro differently than an .m1s macro? Thanks for any help. Tony

Title: Re: Compiling Macro Script
Post by: rrc1962 on June 29, 2011, 09:44:54 AM
I'll second tony's comment.  I can save a button script as a compiled file (.mcc), but when I go back to "Edit Button Script" and click on the button, the original .m1s opens. What I'm trying to do is make it so that button code can not be messed with or even in human readable form...in other words, compiled code.

Edit...

Messing with this more, it appears that I can only save a script as an mcc file if I rename it.  A button script always has the name HiddenScript, so when I try to save it as an mcc file, it just tells me that HiddenScript.m1s already exists and asks to overwrite.  If I rename it to something like HiddenScript1.mcc, it saves as compiled code, but is not attached to the button.
Title: Re: Compiling Macro Script
Post by: BR549 on June 29, 2011, 11:08:29 AM
I don't think you can complie a button script as it is embeded into the screenset. The only other way is to have your button call the compiled macro.

Code"M999"

(;-) TP
Title: Re: Compiling Macro Script
Post by: Tony Bullard on June 29, 2011, 11:32:05 AM
Rcc, if all you want is not to have an operator edit the script how about using Screen4 and disabling “VB Script function edited in Mach3” for the button you’re concerned about?
Tony

I'm trying to insert a picture here but can't figure out how to do it.
Title: Re: Compiling Macro Script
Post by: DaveCVI on June 29, 2011, 11:42:34 AM
Hi,
Look up some more tools in the docs and the pieces will come together....

1) look up RunScript. The call allows a script to call a named disk file which contains other scritpts.
the disk file invoked can be either a .m1s or a .mcc file.
2) compile the code you want into an mcc file.
3) make the button code in the set file be a RunScript line that invokes your compiled code.

This will require use of mach 3.43.xx as the necesary calls are not in the mach 3.42.xx series.

Dave
Title: Re: Compiling Macro Script
Post by: djc on June 29, 2011, 03:19:03 PM
1) look up RunScript. The call allows a script to call a named disk file which contains other scritpts.
the disk file invoked can be either a .m1s or a .mcc file.
2) compile the code you want into an mcc file.
3) make the button code in the set file be a RunScript line that invokes your compiled code.

Other than hiding your macro code from the end-user, could you elaborate on the possible benefits of doing this?

Thanks.
Title: Re: Compiling Macro Script
Post by: DaveCVI on June 29, 2011, 03:32:57 PM
The motivations for doing this are:
1) this removes the script from the set file - it now lives in a disk file instead of in the set file.
That may or may not be important to you depending on what you are doing.
For example, in my  MachStdMill software, this technique is used to let there be only one copy of a routine in one disk file. That's a huge deal when the only alternative is 106 copies of the routine that all live inside the set file. So this approach can be a huge maintenance productivity gain for complicated software. On the flip side, for a single simple button, it's probably more trouble than it's worth.

2) The external disk file  called by RunScript can be either source (m1s) or compiled (mcc). So if you want to use an mcc file (for whatever reason), you pretty much have to make the compiled script live outside the set file.

Dave

1) look up RunScript. The call allows a script to call a named disk file which contains other scritpts.
the disk file invoked can be either a .m1s or a .mcc file.
2) compile the code you want into an mcc file.
3) make the button code in the set file be a RunScript line that invokes your compiled code.

Other than hiding your macro code from the end-user, could you elaborate on the possible benefits of doing this?

Thanks.
Title: Re: Compiling Macro Script
Post by: BR549 on June 29, 2011, 05:00:06 PM
If ALL you want to do is stop the OP from monkeying with the controls simply LOCK the Mach config. that includes the edit button functions.

(;-) TP
Title: Re: Compiling Macro Script
Post by: rrc1962 on July 02, 2011, 12:02:32 AM
I want the user to be able to add buttons and code of their own, just not mess with mine.  Dave's suggestion of using RunScript() worked great.  Button code is now compiled and lives in it's own directory.
Title: Re: Compiling Macro Script
Post by: DaveCVI on July 02, 2011, 01:41:51 AM
 ;D ;D
Dave

I want the user to be able to add buttons and code of their own, just not mess with mine.  Dave's suggestion of using RunScript() worked great.  Button code is now compiled and lives in it's own directory.