Hello Guest it is December 07, 2024, 10:46:38 AM

Author Topic: Proper Entry and Exit sequence for VB macro so that one can call another  (Read 1732 times)

0 Members and 1 Guest are viewing this topic.

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.

Offline TPS

*
  •  2,536 2,536
Re: Proper Entry and Exit sequence for VB macro so that one can call another
« Reply #1 on: December 25, 2018, 05:18:23 AM »
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:

Code: [Select]
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:

Code: [Select]
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.



« Last Edit: December 25, 2018, 05:22:43 AM by TPS »
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.

Offline ger21

*
  • *
  •  6,295 6,295
    • The CNC Woodworker
Re: Proper Entry and Exit sequence for VB macro so that one can call another
« Reply #2 on: December 25, 2018, 10:18:35 AM »
The best bet is to do everything in your M6 macro, rather than multiple macros.
Or do what TPS said.
Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html