Ahh wow... I can't believe I didn't try the -q flag.
My latest problem comes when I try to source the script I've now saved. I'm passing the text from the script editor to a new window, selecting it and then writing it as a .mel into the user's script directory. I am then attempting to use that filepath as a variable to source. However nothing I try gets the source to work properly.
CODE
//Checks for existing window, if one exists it is deleted.
if ( window -exists ssWindow
){
deleteUI ssWindow;
}
//Creates the GUI for the Save/Source script.
else{
window -h 150 -w 500 -t "Save/Source" "ssWindow";
columnLayout;
text "Enter script name";
textField -w 300 -ec ssCommand userIn;
button -align "right" -command ssCommand "Save/Source";
showWindow;
}
//Creates the ssCommand that saves and sources the text in the script editor.
proc ssCommand(){
//Stores the users input into a string and adds ".mel" to the end.
string $userInput = (textField -q -tx userIn
+ ".mel");
delegateCommandToFocusedExecuterWindow("-e -selectAll");
delegateCommandToFocusedExecuterWindow("-e -cp");
//Creates a temporary scroll field and passes the text from the Script editor into it.
if ( window -exists codeWindow
){
deleteUI codeWindow;
}
else{
window "codeWindow";
columnLayout;
cmdScrollFieldExecuter -pst -selectAll -width 1000 -height 200 "codeBox";
//Stores the user's script text into a string.
string $code = cmdScrollFieldExecuter -q -slt codeBox
;
//Creates a .mel file containing the user's script and saves it within the user's script directory.
$filename = (internalVar -userScriptDir
+ $userInput);
$file =fopen $filename "w"
;
fwrite $file $code;
fclose $file;
source $filename;
//Cleans up excess windows.
deleteUI codeWindow;
deleteUI ssWindow;
}
}