SaveFileDialog() always returns empty string
by Jeff Yaskus · in Torque 3D Professional · 06/01/2012 (10:13 pm) · 5 replies
This used to work ... but now it always returns an empty string.
The code below is straight from the T3D scripting manual ... modified for DTS models.
first found it here;
docs.garagegames.com/torque-3d/reference/classSaveFileDialog.html
Then, another version is here ... which doesnt use %openFileDlg.file incorrectly;
docs.garagegames.com/torque-3d/reference/classFileDialog.html
And it was working 12/7/2011 ... unless I was imagining it.
here is a dump of the output
The code below is straight from the T3D scripting manual ... modified for DTS models.
// Create a dialog dedicated to saving a file
%saveFileDlg = new SaveFileDialog()
{
// Only allow for saving of DTS files
Filters = "DTS Files (*.dts)|*.dts|";
// Default save path to where the WorldEditor last saved
DefaultPath = $pref::WorldEditor::LastPath;
// No default file specified
DefaultFile = "";
// Do not allow the user to change to a new directory
ChangePath = false;
// Prompt the user if they are going to overwrite an existing file
OverwritePrompt = true;
};
// Launch the save file dialog
%result = %saveFileDlg.Execute();
// Obtain the file name
%selectedFile = "";
if ( %result )
%selectedFile = %saveFileDlg.file;
// added for debugging
echo("*** selectedFile = (" @ %selectedFile @") ***");
%saveFileDlg.dump();
echo("*** ----------------------------------------- ***")
//
// Cleanup
%saveFileDlg.delete();first found it here;
docs.garagegames.com/torque-3d/reference/classSaveFileDialog.html
Then, another version is here ... which doesnt use %openFileDlg.file incorrectly;
docs.garagegames.com/torque-3d/reference/classFileDialog.html
And it was working 12/7/2011 ... unless I was imagining it.
here is a dump of the output
*** selectedFile = () ***
Class: SaveFileDialog
Static Fields:
bool canSave = "1"
bool canSaveDynamicFields = "1"
bool changePath = "False"
string defaultFile = ""
string defaultPath = "T:\Torque\Torque3D\Recast\T3D_1.2_OEM\My Projects\JeffsTemplate\game"
string fileName = "T:/Torque/Torque3D/Recast/T3D_1.2_OEM/My Projects/JeffsTemplate/game/art/shapes/cube/myCube.dts"
string filters = "DTS Files (*.dts)|*.dts|"
bool hidden = "0"
bool locked = "0"
bool OverwritePrompt = "true"
SimObject parentGroup = "MissionCleanup"
pid persistentId = ""
string title = ""
Dynamic Fields:
Methods:
void assignFieldsFrom( SimObject fromObject )
void assignPersistentId()
string call( string method, string args... )
string clone()
string deepClone()
void delete()
void dump( bool detailed=false )
void dumpClassHierarchy()
void dumpGroupHierarchy()
string dumpMethods()
bool Execute()
bool getCanSave()
string getClassName()
string getClassNamespace()
int getDeclarationLine()
string getDynamicField( int index )
int getDynamicFieldCount()
string getField( int index )
int getFieldCount()
string getFieldType( string fieldName )
string getFieldValue( string fieldName, int index=-1 )
string getFilename()
string getGroup()
int getId()
string getInternalName()
string getName()
string getSuperClassNamespace()
bool isChildOfGroup( SimGroup group )
bool isEditorOnly()
bool isExpanded()
bool isField( string fieldName )
bool isInNamespaceHierarchy( string name )
bool isMemberOfClass( string className )
bool isMethod( string methodName )
bool isNameChangeAllowed()
bool isSelected()
onDefineFieldTypes( string this )
bool save( string fileName, bool selectedOnly=false, string preAppendString="" )
int schedule( float time, string method, string args... )
void setCanSave( bool value=true )
void setClassNamespace( string name )
void setEditorOnly( bool value=true )
void setFieldType( string fieldName, string type )
bool setFieldValue( string fieldName, string value, int index=-1 )
void setFilename( string fileName )
void setHidden( bool value=true )
void setInternalName( string newInternalName )
void setIsExpanded( bool state=true )
void setIsSelected( bool state=true )
void setLocked( bool value=true )
void setName( string newName )
void setNameChangeAllowed( bool value=true )
void setSuperClassNamespace( string name )About the author
Long time gamer, hacker and programmer. With dreams of making video games -
#2
Don't want others running into the same problem ... the examples in the online doc do NOT work as is.
Its just a matter of changing it from .file to .fileName
06/05/2012 (2:30 pm)
My point is -- can we get the ONLINE DOCUMENTS updated so they work? Don't want others running into the same problem ... the examples in the online doc do NOT work as is.
Its just a matter of changing it from .file to .fileName
#3
Site Feedback: http://www.garagegames.com/community/forums/53
may be then it will come into their notich.
06/08/2012 (10:53 pm)
u better post a thread with the suggested fix here:Site Feedback: http://www.garagegames.com/community/forums/53
may be then it will come into their notich.
#4
06/10/2012 (10:56 am)
I tried to move this to the appropriate bug forum, although its just a documentation error
#5
I've logged this as documentation bug TDOC-404.
06/11/2012 (8:37 am)
Thanks Jeff - I'm on it! Hopefully we can get that updated in the online docs before too long - I have an updated version of the RTS Prototype that is going up as soon as it's passed QA, so I'll try to squeeze this in with that update.I've logged this as documentation bug TDOC-404.
Torque Owner Jeff Yaskus
jy games
from:
if ( %result ) %selectedFile = %saveFileDlg.file;to:
if ( %result ) %selectedFile = %saveFileDlg.fileName;And now the file gets created properly