Machsupport Forum

Mach Discussion => Mach Screens => Machscreen Screen Designer => Topic started by: Dennyz on December 16, 2012, 08:05:15 PM

Title: Macros and VB Subroutines/Functions
Post by: Dennyz on December 16, 2012, 08:05:15 PM
Hi all,

I though I would play around with building a custom screen for my Touch Screen Mach3 controller.  I am using MachScreen V1.56. I have been able to put together a working screen using "Execute Basic Script" macros.  I would like to create some Subroutines and Functions to stream line a few things.  I can't for the life of me figure out how to get a button script (for example) to call a subroutine I created in the VB Script Editor. I have read through everything I can find, with no joy.  I put a message box inside the subroutine to see if it was getting called and it is not.  What am I missing?

example code (VB Script Editor):

Public Dim MyDRO as Integer

MyDRO = 1000

sub setdro( value as double)
     setuserdro(MyDRO, value)
end Sub

example code (Button Script Code)

setdro( 1000.0001 )



Title: Re: Macros and VB Subroutines/Functions
Post by: Klaus1311 on December 17, 2012, 03:37:00 AM
 Hi,

save your script as a macro, e.g. m1100.m1s (don't forget .m1s extension.  In your screen just put !Code"m1100"! as "Execute code" (text within the ! !. That should call your script everytime you click your button.



Klaus
Title: Re: Macros and VB Subroutines/Functions
Post by: Dennyz on December 17, 2012, 10:32:45 PM
Klaus,

My script file is named test.m1s.  Do I place !Code"test"! in the Execute code for the button?  I tried this and still nothing happens.
Title: Re: Macros and VB Subroutines/Functions
Post by: Klaus1311 on December 18, 2012, 03:03:14 AM
Hello,

try the following:
name your macro                    m1200.m1s
set the Execute code to:          Code "m1200"


Klaus
Title: Re: Macros and VB Subroutines/Functions
Post by: Dennyz on December 18, 2012, 10:28:44 PM
Klaus,

Still no success

Dennyz
Title: Re: Macros and VB Subroutines/Functions
Post by: Klaus1311 on December 19, 2012, 04:33:26 AM
Hi Dennyz

try this:
copy the attached macro m1150.m1s in your profile dir (standard installation C:\Mach3\macro\ profilename). Add a button to your screen with the following properties:    ( these parameters are for MachScreen)


Global                    No
Function                 Execute Basic-Script   either select this fct or type 34 in the Standard Code line
Standard Code        34
Hotkey
Execute Code         Code "m1150"
Text on ctrl            Macro call
Locked for mouse   No

and save the screen set. Load the new screen in Mach3.


Klaus
Title: Re: Macros and VB Subroutines/Functions
Post by: Dennyz on December 20, 2012, 03:54:51 PM
cool, that worked.
thanks