Page 1 of 1

Open File Dialog for scripting

Posted: 03 Jan 2021, 22:52
by clintonman
I just updated the Clintons3d rsx plugin with a new "FileOpenDialog" function.
Truespace script has a "..." button for selecting files which needs a second button press to actually do something with the selection.

This is a single button open dialog very similar to the plugin "FileSaveAsDialog2" function. It's usage is identical.

http://clintons3d.com/plugins/truespace ... index.html

Code: Select all

var fso = new ActiveXObject("Scripting.FileSystemObject");
var util = System.CreateDO("Clintons3D Package/Utility functions");
var folder = "";
var filename = "";
folder = fso.GetParentFolderName(filename);
filename = fso.GetFileName(filename);
//fso method return of folder or filename is flawed when path is invalid/empty
//causes returned value of plugin to cause tS crash
if(folder=="") folder="";
if(filename=="") filename="";
var defExt = "tga";
var filter = "TGA (*.tga)~*.tga~EXR (*.exr)~*.exr~HDR (*.hdr)~*.hdr~Jpeg (*.jpg)~*.jpg~PNG (*.png)~*.png~TIF (*.tif)~*.tif~All Files (*.*)~*.*~~";
var file = util.FileOpenDialog(folder, filename, filter, defExt);
System.Trace(file);