Hello Guest it is October 26, 2021, 06:19:22 PM

Author Topic: Macros and VB Subroutines/Functions  (Read 12327 times)

0 Members and 1 Guest are viewing this topic.

Macros and VB Subroutines/Functions
« 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 )



Mach3 on a converted Bridgeport
Re: Macros and VB Subroutines/Functions
« Reply #1 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
The brain isn't a soap, it doesn't shrink when used.
Re: Macros and VB Subroutines/Functions
« Reply #2 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.
Mach3 on a converted Bridgeport
Re: Macros and VB Subroutines/Functions
« Reply #3 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
The brain isn't a soap, it doesn't shrink when used.
Re: Macros and VB Subroutines/Functions
« Reply #4 on: December 18, 2012, 10:28:44 PM »
Klaus,

Still no success

Dennyz
Mach3 on a converted Bridgeport
Re: Macros and VB Subroutines/Functions
« Reply #5 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
The brain isn't a soap, it doesn't shrink when used.
Re: Macros and VB Subroutines/Functions
« Reply #6 on: December 20, 2012, 03:54:51 PM »
cool, that worked.
thanks
Mach3 on a converted Bridgeport