Hello Guest it is April 18, 2024, 09:40:48 PM

Author Topic: Starting a VBScript from am Button?  (Read 1570 times)

0 Members and 1 Guest are viewing this topic.

Starting a VBScript from am Button?
« 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

Offline TPS

*
  •  2,505 2,505
    • View Profile
Re: Starting a VBScript from am Button?
« Reply #1 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
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: Starting a VBScript from am Button?
« Reply #2 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

Offline TPS

*
  •  2,505 2,505
    • View Profile
Re: Starting a VBScript from am Button?
« Reply #3 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.
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: Starting a VBScript from am Button?
« Reply #4 on: June 18, 2022, 06:44:30 AM »
ok thanks! i will try it!
Re: Starting a VBScript from am Button?
« Reply #5 on: June 20, 2022, 01:03:09 PM »
works perfect! Thanks!!!!