Hello,
Simply change your "Load Gcode" button to "VBScript" and past this code, or if you would like to call on it to read the current file with out the navigation remove:
DoOEMButton(216)
While(isloading)
sleep(250)
Wend
This code will:
1. Open a file navigation to open Gcode in Mach
2. Look for "M6/M06" and the "T" value
3. Write a file called "StoredM6.txt" in the current directory
4. "StoredM6.txt" will contain: Inc M6 call, Line Number, Tool Number, Name, Diam and Length.
5. Open the text file
If there are no M6's it will display a message.
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim filesys, filetxt, lastline,oldline,Stored_List,StoreFilePath,path,currentfile As String
Dim dTaskID As Double
Dim i,k,j As Integer
DoOEMButton(216)
While(isloading)
sleep(250)
Wend
StoreFilePath = CurDir & "\StoredM6.txt"
path = "C:\WINDOWS\notepad.exe"
Found = False
Stored_List = ""
currentfile = FileName
i = 0
k = 0
j=0
Set filesys = CreateObject("Scripting.FileSystemObject")
Set objTextFile = filesys.CreateTextFile(StoreFilePath)
Set filetxt = filesys.OpenTextFile(currentfile, ForReading, True)
Do While filetxt.AtEndOfStream <> true
linestring = UCase(filetxt.ReadLine()) & " "
If linestring <> " " Then
k = k+1
If ((InStr(linestring,"M6") >0 Or InStr(linestring,"M06")>0)) Then
Found = True
j = j+1
ToolIndex = InStr(linestring,"T")
For d = 3 To 0 Step -1
ToolNum = Mid(linestring,ToolIndex+1,d)
If IsNumeric(ToolNum) Then
N = GetToolDesc(ToolNum)
D = GetToolParam(ToolNum,1)
L = GetToolParam(ToolNum,2)
Exit For
End If
Next d
i = i+1
objTextFile.WriteLine( j & " Line# " & k & " Tool# " & ToolNum & " Name: " & N & " Diam: " & D & " Length: " & L)
End If
End If
Loop
If Found = True Then
dTaskID = Shell(path + " " + StoreFilePath, vbNormalFocus)
Else
MsgBox "No M6/M06 Found"
End If
filetxt.Close
Set filesys = Nothing
Set filetxt = Nothing
objTextFile.Close