621
MACH TOOL BOX / Re: Button Script to search through active Gcode File for NEXT Tool change
« on: March 10, 2013, 10:25:56 PM »
I've used this one for years attached to a button.
Dim currentLine As String
Dim currentfile As String
Dim filesys, filetxt, lastline, oldline As String
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set filesys = CreateObject("Scripting.FileSystemObject")
currentLine = GetOEMDRO(816)
Found = False
currentfile = FileName
Set filetxt = filesys.OpenTextFile(currentfile, ForReading, True)
Dim i As Integer
i = 0
Do While filetxt.AtEndOfStream <> true
linestring = UCase(filetxt.ReadLine()) & " "
If linestring <> " " Then
i = i+1
If i > currentLine Then
If ((InStr(linestring,"M6") >0 Or InStr(linestring,"M06")>0)) Then
SetOEMDRO(816,i)
Found = True
MsgBox "File has been set to line:"& GetOEMDRO(816)&" Your next toolchange position.Your previous line was:"¤tLine
Exit Do
End If
End If
End If
Loop
If Found = False Then
MsgBox "No M6/M06 Found after LINE:"& currentLine
End If
filetxt.Close
Set filesys = Nothing
Set filetxt = Nothing
Dim currentLine As String
Dim currentfile As String
Dim filesys, filetxt, lastline, oldline As String
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set filesys = CreateObject("Scripting.FileSystemObject")
currentLine = GetOEMDRO(816)
Found = False
currentfile = FileName
Set filetxt = filesys.OpenTextFile(currentfile, ForReading, True)
Dim i As Integer
i = 0
Do While filetxt.AtEndOfStream <> true
linestring = UCase(filetxt.ReadLine()) & " "
If linestring <> " " Then
i = i+1
If i > currentLine Then
If ((InStr(linestring,"M6") >0 Or InStr(linestring,"M06")>0)) Then
SetOEMDRO(816,i)
Found = True
MsgBox "File has been set to line:"& GetOEMDRO(816)&" Your next toolchange position.Your previous line was:"¤tLine
Exit Do
End If
End If
End If
Loop
If Found = False Then
MsgBox "No M6/M06 Found after LINE:"& currentLine
End If
filetxt.Close
Set filesys = Nothing
Set filetxt = Nothing