PDA

View Full Version : Open a File Dialog Box in SBP



Charlie_J
10-21-2017, 09:10 AM
Hello,
I'm trying to write a sbp file that allows you to open a sbp file and which then has some additional commands to allow the selected file to run several times in different locations on the machine. I have a program written that already does this but I have to manually go in and change the file name.

So my question is... Is there a way when open a file selection box within a sbp file?

Thanks so much, Charlie
www.joswoodgallery.com

Tim Lucas
10-21-2017, 08:17 PM
The "FP" command will run a file from within a file - so if you wrote a file the has a popup to give you choices of files and set up variables to go to sections to run different files - something like this

'Make First Plunge... the following line will display first and wait for key stroke

MSGBOX(Is &ToolName tool number &tool in spindle? ,YesNoCancel,Change bit?)
if &msganswer = Cancel then ENDALL
if &msganswer = no then GoTo changebit

MSGBOX(Is Z axis zeroed? ,YesNoCancel,ZeroZ)
if &msganswer = Cancel then ENDALL
if &msganswer = YES then GoTo AlreadyZero

the MSGBOX sets up the question
msganswer is the variable
the GoTo sends you to a section of the file which in your case could be file names - then when you get there you run your FP command


hope this made sense

Tim

Gary Campbell
10-21-2017, 08:56 PM
This is an excerpt from something similar I wrote 6-8 years ago:

INPUT "ENTER DOOR HEIGHT [96],[81],[80], Input [C]ustom or [Q]uit" &menu_hgt
'
IF &menu_hgt = Q THEN ENDALL
'
IF &menu_hgt = C THEN GOSUB CUSTOM
'
IF &menu_hgt = 96 THEN GOSUB 96
'
IF &menu_hgt = 81 THEN GOSUB 81
'
IF &menu_hgt = 80 THEN GOSUB 80
'
'ADD ADDITIONAL HERE IF NEEDED (dont forget to add to input at top)
'
MSGBOX(CUT DIFFERENT LENGTH DOORS?,YesNo,[YES] top SELECT NEW LENGTH OR [NO] to QUIT)
IF &msganswer = YES THEN &change_height = YES
IF &msganswer = YES THEN GOTO CHANGE_HGT
'
END
'+++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++
CUSTOM:
FP,C:\SbParts\Fixed Louver Doors\JALOUSIE FIXED LOUVER CUTTER CUSTOM SIZES.sbp
RETURN
'
80:
FP,C:\SbParts\Fixed Louver Doors\FXD LVR 80 TALL.sbp
RETURN
'
81:
FP,C:\SbParts\Fixed Louver Doors\FXD LVR 81 TALL.sbp
RETURN
'
96:
FP,C:\SbParts\Fixed Louver Doors\FXD LVR 96 TALL.sbp
RETURN
'

Charlie_J
10-24-2017, 11:39 AM
Thanks folks for trying to help. I guess both of the solutions are still hard coding the file names into the file. In my case the file folder constantly changes with additional files (I just want to pick the file I need out of the folder they reside in...). I may have to create a VB program that creates a sbp file and then I run the same sbp file all the time. Basically, run the VB program 1st then run the SBP file.

Thanks, Charlie

srwtlc
10-24-2017, 12:09 PM
Not sure if you can get the SHELL command to work for you or not, but this would bring up the open dialog set to a folder of your choosing.

"c:\windows\EXPLORER.EXE /n, /e, c:\SbParts"

Charlie_J
10-26-2017, 10:21 PM
Well, tried your suggestion(s) (Thanks!) but couldn't quite find anything that would open a dialog box from within the SBP code and do what I wanted. So... I went a different way. I used an Excel file and coded some VBA to do it...
Basically the Excel file allows you to select a file that you want to run multiple times shifting between 2 locations. After you select the file it actually writes out a SBP file that you would run. The file will be written to the same folder you select the file from. There is some documentation within the file. You will need to enable macros in order for it to work. Should work in both Excel 2013 and 2016.

Hope this makes sense...

Try in preview mode to see it work.

https://www.dropbox.com/s/at7ekguqvk4fl6v/File%20Picker.xlsm?dl=0

Thanks, Charlie
www.joswoodgallery.com