Machsupport Forum

Mach Discussion => VB and the development of wizards => Topic started by: hitchhiker on June 17, 2022, 08:24:08 AM

Title: Starting a VBScript from am Button?
Post by: hitchhiker on June 17, 2022, 08:24:08 AM
Hi guys...

i build a lathescreen.
now i have on 3 sites the same button with the same code...

if i want to change something on the code i must copy&past it to all 3 sites...

is there a way to to make changes in a .m1s file?

my attemp was:

button starts oem code 34 (basic script)
in the line for the script i put in :

Code "Button1.m1s"

then i make a file in the correct directory with the name Button1.m1s
to test it i put in the file :

Code "F300"


i get error when i hit the button in mach3....

if i  name the file M4444

and change on the button from button1.m1s to m4444.m1s it works.


what do i wrong?! thanks

Title: Re: Starting a VBScript from am Button?
Post by: TPS on June 17, 2022, 01:04:33 PM
have a look to this:

https://www.machsupport.com/wp-content/uploads/2013/02/Mach3_V3.x_Macro_Prog_Ref.pdf

and then look for #Expand maybe this help's
Title: Re: Starting a VBScript from am Button?
Post by: hitchhiker on June 17, 2022, 01:13:16 PM
Thanks.. yes i read it but i dont understand it...

my solution is to use m4444 for the code... but i hope someone have a example what i understand :)

thanks
Title: Re: Starting a VBScript from am Button?
Post by: TPS on June 18, 2022, 06:17:08 AM
you create a macrofile in the holder  c:\Mach3\macros\Your profile name
let's say MyFuntions.m1s

in the file MyFuntions.m1s you place a function with the code:
Code: [Select]
'function for button1 ------------------------------------------------
Function Button1() as Boolean

        Code ("F300")
End Function

now in any button you can use this code:
Code: [Select]
Sub Main()
Call Button1()
End Sub

#Expand <\..\..\macros\Your profile name\MyFunctions>

so you can keep the specific code in just one file -> MyFunctions.m1s
and you can add as may functions you want.
Title: Re: Starting a VBScript from am Button?
Post by: hitchhiker on June 18, 2022, 06:44:30 AM
ok thanks! i will try it!
Title: Re: Starting a VBScript from am Button?
Post by: hitchhiker on June 20, 2022, 01:03:09 PM
works perfect! Thanks!!!!