this Version should work on every OS:
'Gcode Selection Box
Sub GcodeSelect
Dim MyList()
Begin Dialog GcodeFileDlg 60, 60, 190, 220, "Gcode file selection", .DlgFunc
ListBox 10, 10, 150, 180, MyList(), .List1, 2
CancelButton 42, 198, 40, 12
OKButton 90, 198, 40, 12
End Dialog
Dim frame As GcodeFileDlg
' Show the GcodeFile dialog
Dialog frame
End Sub
Function DlgFunc( controlID As String, action As Integer, suppValue As Integer)
DlgFunc = 1 ' Keep dialog active
Select Case action
Case 1 ' Initialize
temp = Dir( "c:\Mach3\Gcode\*.tap" )
count = 0
While temp <> ""
count = count + 1
temp = Dir
Wend
Dim x() As String
ReDim x(count)
x(0) = Dir( "c:\Mach3\Gcode\*.tap" )
For i = 1 To count
x(i) = Dir
Next i
DlgListBoxArray "List1", x()
Case 2 ' select
Fname = (DlgText("List1"))
Dim FileName As String
FileName = "c:\Mach3\Gcode\" &Fname
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 whole file
Do While Not EOF(FNumInput)
Line Input #FNumInput, FileData ' Read a line of data.
If ((InStr(FileData,"G43") <> 0) And (Left(FileData,1) <> "(")) Then
Print #FNumOutput, "( " + FileData + " )"
Else
Print #FNumOutput, FileData
End If
Loop
Close ' Close all open files.
LoadFile( "C:\Mach3\GCode\" + blancfilename + "_filtered" + extension)
End
End Select
End Function