[Solved] Using toString() method to alert directory path...

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
sbaden
Posts: 35
Joined: June 16th, 2009, 1:07 pm
Location: Santa Clarita, CA

I'm trying to alert users to the location renders were saved by using the toString() method.

The resulting alert gives a %20 instead of a space. How do I correct this?


alert("Please select a render folder.\r\n"+
"When the script has finished you will collect your renders from this folder location.");
var newRenderLocation = folderGetDialog("Select a destination to render comps.");

alert("Render Complete. \r\n" +
"Collect renders from saved location." + newRenderLocation.toString());


Any help is much appreciated,
Shawn
Last edited by sbaden on December 29th, 2009, 2:15 pm, edited 1 time in total.
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

Here's an example showing one way to do it. It uses the .split() string method, to break the original string into an array of strings separated by occurrences of %20. Then it puts them back together with spaces between them.

Code: Select all

var theString = "text%20with%20spaces"
var theSplit = theString.split("%20");

var newString = theSplit[0];
for (x = 1; x < theSplit.length; x++) {
	newString += " " + theSplit[x];
}

alert(">" + newString + "<");
sbaden
Posts: 35
Joined: June 16th, 2009, 1:07 pm
Location: Santa Clarita, CA

Hey Paul... awesome. Thank you very much. I'll give this a shot. :D
sbaden
Posts: 35
Joined: June 16th, 2009, 1:07 pm
Location: Santa Clarita, CA

Thanks again Paul!

I tried out the code and it works perfectly. I'm sure it is a very beginner thing but hey, I'm a beginner so thanks for the help.
nab
Posts: 203
Joined: November 29th, 2005, 3:00 am
Location: Royan
Contact:

You could also use the built-in function decode(). Every special character will be decoded.

Code: Select all

alert(Folder.decode(newRenderLocation));
sbaden
Posts: 35
Joined: June 16th, 2009, 1:07 pm
Location: Santa Clarita, CA

Awesome! Thank you so much. It works perfectly! :D
Post Reply