Machsupport Forum
Mach Discussion => VB and the development of wizards => Topic started by: GordonW on February 19, 2013, 09:59:37 AM
-
I am currently constructing a new screen that mimics an ANCA laser controller.
My first problem is I want to set path and filetype to a default for loading gcode.
When using the OEMButton on my offline test PC, the OpenFile dialogue box shows the last folder I visited with any software. I want to make the system foolproof and give the operators no reason to be searching the hard drive.
As the screen set created by MachScreen is based on milling set the default filetype is TAP - I need it be, for example, NCP, as I also have milling programs on my system.
Also, the operators often type in their own programs. I can create a new file by closing the current file (169) and running the editor (115). How I get the file to load after saving?
Does anyone have open source equivalents of OEMs?
-
As far as I know it is NOT possible t lock it all down with a standard Mach3 profile.
It may be possible by using a CB text box but you would have to custom program a CB equivilent to the Windows File window.
Just a thought, (;-) TP
-
Unfortunately, The only way you could do what you want, is via a plugin, in the plugin you can define the "File Path" and type.
When you press your "Open File", button, that would actually run a VB notifiyplugins or you could flip and LED what ever...
then a plugin driven dialog box would appear that was locked down to the file path/folder you want your users to pull from.
The same would be true to "Save" files.
Using VB you can also do Loadfile and RunFile type commands in where you specify,
the file you want to load or run. For dynamic in that case you would have to have a Macropump or cyclic macro running, and
fill in a message box.
Scott
-
Thanks. I'll look at plugins
-
Just popup your own file open/save dialog from CB then you can do what you like with it
I described how to do it here (but note this only works on XP)
www.machsupport.com/forum/index.php/topic,19852.0.html (http://www.machsupport.com/forum/index.php/topic,19852.0.html)
Then you'd just call the loadfile, runfile combo.
Note: at the end of that thread a kind soul came along afterwards and suggested a way that he says works on any windoze version.
Ian
-
I tried the OTHER solutions and they did NOT work in Vista HERE.
I can see HOW to build the list(recursive function) and list box for selection BUT get lost in the logic again.
(;-) TP
-
OK I have gotten this far with a list box and am stuck again. Not sure how to apply the selected file to LOADFILE(). It also has a error I cannot figure out when you select the file ????
'Gcode Selection Box
Sub GcodeSelect
Dim MyList()
Begin Dialog BitmapDlg 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 BitmapDlg
' Show the bitmap 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 ' Click
fileName = "c:\Mach3\Gcode\" & DlgText("List1")
End Select
End Function
End
-
OK have it selecting the file and USE loadfile() to load , BUT now I cannot close out the BOX when the file is selected AND IF I use the cancel it reloads the file again.
(;-) TP
-
Unfortunately Plugins not an option at the moment - need £1,000+ for Visual Studio to access MFC. Though I am happy to be able to stay with VB rather than learn c++
-
This Button code will do the job. It just does not cancel gracefully(;-).
'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"))
LoadFIle("c:\Mach3\Gcode\" &DlgText("List1"))
End
End Select
End Function
End
-
Terry - loose the line...
DlgFunc = 1 ' Keep dialog active
and change your case 2 code to ...
If controlID = "OK" Then
LoadFIle("c:\Mach3\Gcode\" &DlgText("List1"))
End If
Ian
-
Thanks Ian that did the trick(;-).
When you have a spare moment(;-)
Is it possible to List files that are *.tap AND *.txt ?
In the list is is possible to have a large font(touchscreen use) and a space between each line?
Thanks again, Some day I might get the full hang of this programming BUT I fear that when Mach4 arrives I will have to fold up shop. It is far more complex than the simple CB is.
(;-) TP
-
well as a quick and dirty you could change the file spec filter to *.t??
which would list all files with a 3 letter extension where the first letter is t
I fear that when Mach4 arrives I will have to fold up shop. It is far more complex than the simple CB is.
care to expand? what's the plan for scripting?
Ian
-
Mach4 scripting will be LUA.
(;-) TP
-
Excellent!
-
Easy for you to say(;-) LOL
(;-) TP
-
Thanks all. Now I've got something to work with.