Create a working directory

About Truespace Archives

These pages are a copy of the official truespace forums prior to their removal somewhere around 2011.

They are retained here for archive purposes only.

Create a working directory // Interactive Artwork

1  |  

Post by Shell1850 // Feb 4, 2009, 12:18pm

Shell1850
Total Posts: 13
I am trying to path to a folder with all the objects and scripts using jscript. I plan to click on a file in the working folder and have the jscript remove the file leaving the path to the folder. i used the split method and us '\' to seperate the different folders. The '\' generates a error "unterminated string constant" when i try to compile it.


Right now i select the a file in the folder I want to use and remove the file name.


can anyone help me

Post by Jack Edwards // Feb 4, 2009, 12:31pm

Jack Edwards
Total Posts: 4062
pic
This should do it for you:


function StripPath(Str)
{
var pos = Str.lastIndexOf('\\');
if (pos > 0)
{
return Str.substring(0, pos + 1);
}
return Str;
}


Remember that '\' is an escape character so to actually get a \ you need to use '\\'.

Also be aware that JScript uses a single quote to begin and terminate a string.

Post by Shell1850 // Feb 4, 2009, 12:55pm

Shell1850
Total Posts: 13
Fanstastic


Clean and effiicient.


Thanks Jack Edwards

Post by Jack Edwards // Feb 4, 2009, 2:44pm

Jack Edwards
Total Posts: 4062
pic
Welcome! :D
Awportals.com is a privately held community resource website dedicated to Active Worlds.
Copyright (c) Mark Randall 2006 - 2024. All Rights Reserved.
Awportals.com   ·   ProLibraries Live   ·   Twitter   ·   LinkedIn