|
Post by dagnabitboy on Feb 19, 2020 13:07:32 GMT -5
I'm using the filedialog to write a file. I've specified the file dialog with folder and file type info (*.gcode), and I've preloaded the filename spec. Filedialog correctly opens the desired folder and fills in the file type, but the file name field only contains the desired extension (*.gcode). I was hoping I could specify the entire filename to be written, so the user could just click "save", but also have the option of editing the filename if desired. If this is the first time writing to this folder, then no files are shown in the filedialog, and even if other files are shown, they may not be the desired (suggested by the program) file name.
Does anyone have a work around for this? Thanks in advance!!
|
|
|
Post by sarossell on Feb 19, 2020 13:24:25 GMT -5
You should be able to specify the entire path, filename and extension.
v.Path$ = "myfile.gcode"
filedialog "Save As...", v.Path$ , v.InFile$ if v.InFile$ = "" then end else open v.InFile$ for binary as #InFile end if
print #InFile, "test" close #InFile
end
|
|
|
Post by dagnabitboy on Feb 19, 2020 13:49:10 GMT -5
Wow! Thanks for the quick reply!! I tried your sample code, which works perfect... but.. I guess I don't understand what I'm looking at!
I'm guessing Path$ and InFile$ are reserved keywords, but I'm not finding them in the 4.5.1 reference. Perhaps I just missed them. And I'm also not sure how the "v." comes into play. Dang. I feel like such a noob!
Would you mind expanding my limited knowledge a little! thanks!
|
|
|
Post by Rod on Feb 19, 2020 14:22:38 GMT -5
Its quite straight forwards. You supply the preferred directory and file name in a template string. The response comes back as a string, in this case chosenpathfilename$. The user can change whatever they wish if they don't want the default you specified in the template$.
template$ = "c:\atemp\mynewfile.dat"
filedialog "Save",template$,chosenpathfilename$ print chosenpathfilename$
|
|
|
Post by dagnabitboy on Feb 19, 2020 14:29:31 GMT -5
Thanks Rod, I was not specifying my template$ var correctly. I had the path in it, but without the actual file name.
Problem solved! Thank you Rod and sarossell!
|
|
|
Post by sarossell on Feb 19, 2020 15:37:47 GMT -5
Right, sorry for the "v." stuff. I have some really bad, old programming habits. I'll be sure to use more user-friendly names in the future. Glad you got it worked out!
:@)
|
|