Hello Guest it is March 28, 2024, 01:37:16 PM

Author Topic: Search function  (Read 3819 times)

0 Members and 1 Guest are viewing this topic.

Search function
« on: November 24, 2009, 06:46:54 PM »
It would be great if we could have access to a search function inside the Gcode window like search for the next tool change, next M01.

This could be a great add on since the line number in the Gcode window does not always match the one in the edit window,

Just an idea.

Jeff

Offline Chaoticone

*
  • *
  •  5,624 5,624
  • Precision Chaos
    • View Profile
Re: Search function
« Reply #1 on: November 25, 2009, 06:44:20 PM »
Thats a good idea. I don't know if it is doable but it a good one I think.

Brett
;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!

Offline zealous

*
  •  489 489
  • HI!
    • View Profile
    • Artsoft Solutions
Re: Search function
« Reply #2 on: December 29, 2009, 03:58:13 AM »
this will look for M6/M06 but you can simply change it to look for whatever you want and it will highlight that line in the Gcode for you...but you will tell it what to do after that example: (RFH or SetNextLine)

Code: [Select]
Dim currentfile As String
Dim filesys, filetxt, lastline, oldline As String
Dim currentLine 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:"&currentLine
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

thanks,
Jason Blake
Re: Search function
« Reply #3 on: December 31, 2009, 10:56:32 PM »
Can I modify the script to count how many M03's are there? and detect which line number the M03's are?

Offline zealous

*
  •  489 489
  • HI!
    • View Profile
    • Artsoft Solutions
Re: Search function
« Reply #4 on: January 12, 2010, 09:39:34 PM »
sorry I did not know you posted...

this will save the positions of the M6's to a text file located in the Mach3 directory, then open it if it finds M6,listing the line number and content on those lines.
Just change the
Code: [Select]
If ((InStr(linestring,"M6") >0 Or InStr(linestring,"M06")>0)) Then to M3 ;)

Code: [Select]
Dim currentfile As String
Dim filesys, filetxt, lastline, oldline As String
Dim currentLine As String
Dim dTaskID As Double, path As String, StoreFilePath As String
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set filesys = CreateObject("Scripting.FileSystemObject")
StoreFilePath = CurDir & "\StoredM6.txt"
path = "C:\WINDOWS\notepad.exe"
Set objTextFile = filesys.CreateTextFile(StoreFilePath)
currentLine = GetOEMDRO(816)
Found = False
currentfile = FileName
Set filetxt = filesys.OpenTextFile(currentfile, ForReading, True)
Dim i As Integer
i = -1
j=0
Do While filetxt.AtEndOfStream <> true
linestring = UCase(filetxt.ReadLine()) & " "
If linestring <> " " Then
i = i+1
If ((InStr(linestring,"M6") >0 Or InStr(linestring,"M06")>0)) Then
j = j+1
objTextFile.WriteLine(j & " " & "Line# " & i & " " & linestring)
Found = True
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
« Last Edit: January 12, 2010, 09:44:42 PM by zealous »