Code: Select all
Option Explicit
Dim oldtool As Integer
Dim newtool As Integer
Dim tcatcp As Integer
Dim tcatlo As Integer
Dim tloptl As Integer
Dim skiprh As Integer
Dim NRH As Integer
'getting initial values
skiprh = getoemled(1726)
tloptl = getoemled(1764)
tcatlo = getoemled(1711)
tcatcp = getoemled(1709)
'looking for RH/NRH tool setting - 0 if RH tool
NRH = InStr(1, GetToolDesc(GetSelectedTool()), "NRH")
message "M606 Start"
oldtool = Getoemdro (1824)
newtool = GetSelectedTool()
If newtool <> oldtool And newtool > 0 Then
If NRH = 0 And skiprh <> 0 Then Call RunScript("ScreenSetMacros\" & GetActiveScreenSetName() & "\" & "Masters\Scripts\Common\RHTHolders")
sleep 50
If NRH = 0 And tloptl <> 0 Then Call RunScript("ScreenSetMacros\" & GetActiveScreenSetName() & "\" & "Masters\Scripts\Common\TCAutoTLOFromPTL")
sleep 50
If NRH = 0 And tcatlo <> 0 Then Call RunScript("ScreenSetMacros\" & GetActiveScreenSetName() & "\" & "Masters\Scripts\Common\TCAutoTLO")
sleep 50
If NRH = 0 And tcatcp <> 0 Then Call RunScript("ScreenSetMacros\" & GetActiveScreenSetName() & "\" & "Masters\Scripts\Common\TCAutoTCP")
sleep 50
message "M6ATC Start"
code "M6T" & newtool
sleep 1000
'wait for M6ATC to finish
While getoemled(1725) <> 0
sleep 250
Wend
message "M6ATC Ended"
'restoring initial settings
If tcatcp <> 0 And getoemled(1709) = 0 Then Call RunScript("ScreenSetMacros\" & GetActiveScreenSetName() & "\" & "Masters\Scripts\Common\TCAutoTCP")
sleep 50
If tcatlo <> 0 And getoemled(1711) = 0 Then Call RunScript("ScreenSetMacros\" & GetActiveScreenSetName() & "\" & "Masters\Scripts\Common\TCAutoTLO")
sleep 50
If tloptl <> 0 And getoemled(1764) = 0 Then Call RunScript("ScreenSetMacros\" & GetActiveScreenSetName() & "\" & "Masters\Scripts\Common\TCAutoTLOFromPTL")
sleep 50
If skiprh <> 0 And getoemled(1726) = 0 Then Call RunScript("ScreenSetMacros\" & GetActiveScreenSetName() & "\" & "Masters\Scripts\Common\RHTHolders")
sleep 50
End If
message "M606 End"
Code: Select all
Sub MSMRunScript(ByVal MSMScriptName As String, ByVal P1 As Double)
' This is a wrapper that will allow one to replace the functionality of "Call Mxxxx Px".
' In fact this it is a bit more capable as the param is implemented as an Global MSM userspace DRO,
' so the script could actually put a value back in the param DRO if needed.
' This could also be expanded to more params, but MSM only was used one param for prior MSM Mxxx macros.
' param type choices where double DRO or LEDs - used DROs as the more flexible approach,
' LED parameters will be encoded within MSM as 0/1 value in the DRO.
'
Dim QFN As String
Dim result as integer
SetUserDRO(MSMRunScriptParam1DRO, P1) ' stash the param value in the allocated Global DRO
QFN = "ScreenSetMacros\" & GetActiveScreenSetName() & "\" & MSMScriptName
'MsgBox "Script to run: " & Chr(13) & " " & QFN & Chr(13) & "Param value = " & P1
result = RunScript(QFN) ' I didn't always check the return value of RS As in 3.43.2 and prior with the RS call, it is always true -
' updated the Code when that got better in later versions of mach
if result < 0 then
' error - script was not run
message "MSMRunScript Error " & chr(13) & _
"Script to be run: " & Chr(13) & " " & QFN & Chr(13) & "Param value = " & P1 & Chr (13) & _
"Error = " & RSErrorText(result)
msgbox "Script to be run: " & Chr(13) & " " & QFN & Chr(13) & "Param value = " & P1 & Chr (13) & _
"Error = " & RSErrorText(result), 48, "MSMRunScript Error."
end if
End Sub
Dave