2101
General Mach Discussion / Re: G49 on Mach3 Mill
« on: February 05, 2018, 05:57:11 AM »
ok here is my Little solution to run in a button script:
it will only work on a machine where Excel is present,
because all my known openfile dialogs (in VBScript) where
not working on a 64bit OS
Thomas
so if anybody has a working fileopen Dialog, would be nice to share it.
Code: [Select]
Sub Main()
Set objFiles = CreateObject("Excel.Application")
Dim Filename As String
'set default open file folder
ChDrive "C:"
ChDir "C:\Mach3\GCode"
FileName = objFiles.Application.GetOpenFilename("GCodeFiles (*.TAP), *.tap")
If FileName = "False" Then Exit Sub
'find the last "\" in filename
For i = 1 To Len(FileName)
If Mid(FileName,i,1) = "\" Then
last = i
End If
Next i
'extract filename
myfilename = Mid(FileName,last+1,Len(FileName)-last)
'find the extension in filename
For i = 1 To Len(myfilename)
If Mid(myfilename,i,1) = "." Then
last = i
End If
Next i
'seperate filename and extension
blancfilename = Mid(myfilename,1,last-1)
extension = Mid(myfilename,last,Len(FileName)-last)
'open input file
FNumInput = FreeFile 'Determine next file number.
Open FileName For Input As FNumInput
'open output file
FNumOutput = FreeFile 'Determine next file number.
Open "C:\Mach3\GCode\" + blancfilename + "_filtered" + extension For Output As FNumOutput
'go through To hole file
Do While Not EOF(FNumInput)
Line Input #FNumInput, FileData ' Read a line of data.
If InStr(FileData,"G43") = 0 Then
Print #FNumOutput, FileData
Else
Print #FNumOutput, "( " + FileData + " )"
End If
Loop
Close ' Close all open files.
End Sub
it will only work on a machine where Excel is present,
because all my known openfile dialogs (in VBScript) where
not working on a 64bit OS
Thomas
so if anybody has a working fileopen Dialog, would be nice to share it.