Hello Guest it is March 29, 2024, 02:21:12 AM

Author Topic: Button/VB script  (Read 10070 times)

0 Members and 1 Guest are viewing this topic.

Button/VB script
« 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?

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Button/VB script
« Reply #1 on: February 19, 2013, 10:22:25 AM »
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

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: Button/VB script
« Reply #2 on: February 20, 2013, 07:44:01 AM »
     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
fun times
Re: Button/VB script
« Reply #3 on: February 20, 2013, 08:32:37 AM »
Thanks. I'll look at plugins

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: Button/VB script
« Reply #4 on: February 20, 2013, 10:15:18 AM »
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

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

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Button/VB script
« Reply #5 on: February 20, 2013, 01:49:20 PM »
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

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Button/VB script
« Reply #6 on: February 20, 2013, 02:34:30 PM »
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

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Button/VB script
« Reply #7 on: February 20, 2013, 03:36:50 PM »
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
Re: Button/VB script
« Reply #8 on: February 21, 2013, 06:42:59 AM »
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++

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Button/VB script
« Reply #9 on: February 21, 2013, 09:46:09 AM »
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