Open File Dialog for scripting

Post Reply
User avatar
clintonman
Captain
Posts: 5422
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Open File Dialog for scripting

Post 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); 
Clinton Reese

http://clintons3d.com
Post Reply