Hello Guest it is November 16, 2019, 05:32:16 PM

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - TPS

991
General Mach Discussion / Re: G49 on Mach3 Mill
« on: February 05, 2018, 02:26:14 PM »
--> cancel buttons appear to have the same effect as the ok buttons Wink

that is a "side" effect from --> Persistent file dialogues

because the Dialog1.FileName has now allready a value in.

i will have a look tomorrow, how to get the value out witch button was pressed.
 
Thomas


992
General Mach Discussion / Re: G49 on Mach3 Mill
« on: February 05, 2018, 01:30:06 PM »
ok here is the Version with pathes remembered and Abort on the wright place

used Userlabel 200 and 201 just Change if allready in use

Code: [Select]
Sub Main()
'get the source file
Dim Filename As String
Dim Dialog1

    Set Dialog1 = CreateObject("MSComDlg.CommonDialog")
    Dialog1.MaxFileSize = 256
    Dialog1.Filter = "GCode Files (*.tap)|*.tap"
    Dialog1.FilterIndex = 1
    Dialog1.DialogTitle = "select GCode file"
    Dialog1.InitDir = "C:\Mach3\GCode"
    'get the last selection
    Dialog1.FileName = GetUserLabel(200)
    save = false
    If save = true Then
        Dialog1.DefaultExt = def
        Dialog1.Flags = &H800 + &H4
        discard = Dialog1.ShowSave()
    Else
        Dialog1.Flags = &H1000 + &H4 + &H800
        discard = Dialog1.ShowOpen()
    End If

FileName = Dialog1.FileName
If Len(FileName) = 0 Then Exit Sub
'store last selection
SetUserLabel(200,FileName)

'get the destination folder
Dim destfile As String

    Dialog1.DialogTitle = "select destination folder and filename"
    'get the last selection
    Dialog1.FileName = GetUserLabel(201)

    save = true
    If save = true Then
        Dialog1.DefaultExt = def
        Dialog1.Flags = &H800 + &H4
        discard = Dialog1.ShowSave()
    Else
        Dialog1.Flags = &H1000 + &H4 + &H800
        discard = Dialog1.ShowOpen()
    End If

destfile = Dialog1.FileName

If Len(destfile) = 0 Then Exit Sub
'store last selection
SetUserLabel(201,destfile)

'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\import.txt" 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.
DoOEMButton(169) 'close Mach3 files just in case
SourceFile = "C:\Mach3\GCode\import.txt"

FileCopy SourceFile, destfile ' Copy source to target.
Kill SourceFile
LoadFile( destfile)

End Sub



993
General Mach Discussion / Re: G49 on Mach3 Mill
« on: February 05, 2018, 01:19:16 PM »
have you used any UserLabel's ?
if yes, witch ?
probably i can use two free ones to store the last pathe's in.

994
VB and the development of wizards / file open/save dialog box in Win7 64bit
« on: February 05, 2018, 11:59:45 AM »
after spending o couple of hour's to get a file open/save Dialog working on win7 64bit,
i post the code here in case somebody else is searching for the same Problem

Code: [Select]

Dim Filename As String
Dim Dialog1

    Set Dialog1 = CreateObject("MSComDlg.CommonDialog")
    Dialog1.MaxFileSize = 256
    Dialog1.Filter = "GCode Files (*.tap)|*.tap"
    Dialog1.FilterIndex = 1
    Dialog1.DialogTitle = "select GCode file"
    Dialog1.InitDir = "C:\Mach3\GCode"
    Dialog1.FileName = ""
    save = false
    If save = true Then
        Dialog1.DefaultExt = def
        Dialog1.Flags = &H800 + &H4
        discard = Dialog1.ShowSave()
    Else
        Dialog1.Flags = &H1000 + &H4 + &H800
        discard = Dialog1.ShowOpen()
    End If

FileName = Dialog1.FileName



change the variable "save", to get either a open or save Dialog

if the code causes a error run this code

Code: [Select]
'Make the MSComDlg.CommonDialog class available for use. Required for filedialog function.
function registerComDlg
    Set objRegistry = GetObject("winmgmts:\\.\root\default:StdRegProv")
    objRegistry.CreateKey &H80000001, "Software\CLASSES\Licenses\4D553650-6ABE-11cf-8ADB-00AA00C00905"
    objRegistry.SetStringValue &H80000001, "Software\CLASSES\Licenses\4D553650-6ABE-11cf-8ADB-00AA00C00905", "", "gfjmrfkfifkmkfffrlmmgmhmnlulkmfmqkqj"
end function


in vb scripter window once to registrate MSComDlg.CommonDialog on your System

Thomas


995
General Mach Discussion / Re: G49 on Mach3 Mill
« on: February 05, 2018, 11:39:23 AM »
ok, everything selectable by dialogbox

Code: [Select]
Sub Main()
'get the source file
Dim Filename As String
Dim Dialog1

    Set Dialog1 = CreateObject("MSComDlg.CommonDialog")
    Dialog1.MaxFileSize = 256
    Dialog1.Filter = "GCode Files (*.tap)|*.tap"
    Dialog1.FilterIndex = 1
    Dialog1.DialogTitle = "select GCode file"
    Dialog1.InitDir = "C:\Mach3\GCode"
    Dialog1.FileName = ""
    save = false
    If save = true Then
        Dialog1.DefaultExt = def
        Dialog1.Flags = &H800 + &H4
        discard = Dialog1.ShowSave()
    Else
        Dialog1.Flags = &H1000 + &H4 + &H800
        discard = Dialog1.ShowOpen()
    End If

FileName = Dialog1.FileName



'get the destination folder
Dim destfolder As String
Dim destfile As String

    Dialog1.DialogTitle = "select destination folder and filename"

    save = true
    If save = true Then
        Dialog1.DefaultExt = def
        Dialog1.Flags = &H800 + &H4
        discard = Dialog1.ShowSave()
    Else
        Dialog1.Flags = &H1000 + &H4 + &H800
        discard = Dialog1.ShowOpen()
    End If

destfolder = CurDir
destfile = Dialog1.FileName

If Len(FileName) = 0 Then Exit Sub
If Len(destfolder) = 0 Then Exit Sub
If Len(destfile) = 0 Then Exit Sub

'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\import.txt" 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.
DoOEMButton(169) 'close Mach3 files just in case
SourceFile = "C:\Mach3\GCode\import.txt"

FileCopy SourceFile, destfile ' Copy source to target.
Kill SourceFile
LoadFile( destfile)

End Sub



996
General Mach Discussion / Re: G49 on Mach3 Mill
« on: February 05, 2018, 10:15:04 AM »
here we go:

file is stored in c:\mach3\gcode with original filename

Code: [Select]
Sub Main()

Dim Filename As String
Dim Dialog1

    Set Dialog1 = CreateObject("MSComDlg.CommonDialog")
    Dialog1.MaxFileSize = 256
    Dialog1.Filter = "GCode Files (*.tap)|*.tap"
    Dialog1.FilterIndex = 1
    Dialog1.DialogTitle = "select GCode file"
    Dialog1.InitDir = "C:\Mach3\GCode"
    Dialog1.FileName = ""
    save = false
    If save = true Then
        Dialog1.DefaultExt = def
        Dialog1.Flags = &H800 + &H4
        discard = Dialog1.ShowSave()
    Else
        Dialog1.Flags = &H1000 + &H4 + &H800
        discard = Dialog1.ShowOpen()
    End If

FileName = Dialog1.FileName
 
If Len(FileName) = 0 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\import.txt" 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.
DoOEMButton(169) 'close Mach3 files just in case
SourceFile = "C:\Mach3\GCode\import.txt"
destfile  = "C:\Mach3\GCode\" + myfilename

FileCopy SourceFile, destfile ' Copy source to target.
Kill SourceFile
LoadFile( "C:\Mach3\GCode\" + myfilename)

End Sub

997
General Mach Discussion / Re: G49 on Mach3 Mill
« on: February 05, 2018, 09:39:07 AM »
ok next Version witch has got a "better" file open Dialog box:

Code: [Select]
Sub Main()

Dim Filename As String
Dim Dialog1

    Set Dialog1 = CreateObject("MSComDlg.CommonDialog")
    Dialog1.MaxFileSize = 256
    Dialog1.Filter = "GCode Files (*.tap)|*.tap"
    Dialog1.FilterIndex = 1
    Dialog1.DialogTitle = "select GCode file"
    Dialog1.InitDir = "C:\Mach3\GCode"
    Dialog1.FileName = ""
    save = false
    If save = true Then
        Dialog1.DefaultExt = def
        Dialog1.Flags = &H800 + &H4
        discard = Dialog1.ShowSave()
    Else
        Dialog1.Flags = &H1000 + &H4 + &H800
        discard = Dialog1.ShowOpen()
    End If

FileName = Dialog1.FileName
 
If Len(FileName) = 0 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 Sub




if this code is causing error's please run this code once in VB scripter window to Register MSComDlg.CommonDialog :

Code: [Select]
   Set objRegistry = GetObject("winmgmts:\\.\root\default:StdRegProv")
    objRegistry.CreateKey &H80000001, "Software\CLASSES\Licenses\4D553650-6ABE-11cf-8ADB-00AA00C00905"
    objRegistry.SetStringValue &H80000001, "Software\CLASSES\Licenses\4D553650-6ABE-11cf-8ADB-00AA00C00905


Thomas,
who never thought a simple open file Dialog will drive him crazy.


998
General Mach Discussion / Re: G49 on Mach3 Mill
« on: February 05, 2018, 08:40:24 AM »
this Version should work on every OS:

Code: [Select]

'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






999
General Mach Discussion / Re: G49 on Mach3 Mill
« on: February 05, 2018, 08:19:24 AM »
witch os are you running on?

1000
General Mach Discussion / Re: G49 on Mach3 Mill
« on: February 05, 2018, 06:30:40 AM »
next Little bugfix,

add

Code: [Select]

LoadFile( "C:\Mach3\GCode\" + blancfilename + "_filtered" + extension)


at the end, to load "cleaned" file imediatelly.