Machsupport Forum
Mach Discussion => General Mach Discussion => Topic started by: Bruce Griffing on December 24, 2018, 05:24:32 PM
-
I have a 15 tool changer and a tool probe. I have written macros that do the tool change and set tool offset. But when I try to put the tool change macro inside another macro - all **** breaks loose. Is it a matter of using the proper entry and exit sequences? Or will it never work. I could of course make a giant macro that does both - sets all 15 tools. But it would be nice if one macro could call another.
-
to call a macro within a macro is a nogo in Mach3, i think it is written somewhere in the documantation.
a good alternative is to us the #expand instruction of cypress.
for example create a file mylibary.m1s in your macro Folder, put some code (Sub's or function's) in:
Public Sub DoThis()
MsgBox "Sub DoThis was called"
End Sub
Public Sub DoThat(ByVal X as Long,ByVal Y as Long)
MsgBox "Sub DoThat was called with parameter X: " + CStr(X) +" parameter Y. " + CStr(Y)
End Sub
Public Function DoThiswithreturn (ByVal X As Integer) As Boolean
If X > 100 Then
DoThiswithreturn = true
Else
DoThiswithreturn = false
End If
End Function
put at the end of your macro witch whants to use this routines this:
#Expand <\..\..\macros\Mach3Mill\mylibary>
sample for macro would be:
Sub Main
Dim RetValue As Boolean
DoThis
DoThat 1,2
RetValue = DoThiswithreturn(50)
MsgBox RetValue
RetValue = DoThiswithreturn(150)
MsgBox RetValue
End Sub
#Expand <\..\..\macros\Mach3Mill\mylibary>
you can use this exand in all macros witch whant to use the same routines.
-
The best bet is to do everything in your M6 macro, rather than multiple macros.
Or do what TPS said.