Problems with String functions...

I am having some strange problems with the String functions built in to the JSLib. They began when I was trying to use the Concat() function; I basically got a blank string anytime I tried to use it. Strange, I thought, but I was able to overcome that with the “+” operator.

What I can’t find a workaround for is the lastIndexOf() function, and this is what convinced me there was something afoot. I tried everything I could think of to get this simple snippet of code to work:

var fullPath = plugins.file.showFileOpenDialog(1); //works fine
file_path = fullPath; //saves the path to the selectedrecord

var lastSep = fullPath.lastIndexOf("/"); //crashes and burns!

Specifically, the error I get is “lastIndexOf is not a function.” But yes, it is! I have tried it both with and without the second argument.

So, am I doing something wrong? All the online examples I saw indicate this is the correct syntax. So then, I have to ask whether something is wrong with Servoy or my particular installation? I’m running on Mac OS X 10.4.2 with the latest release (2.2) of Servoy.[/code]

You are trying to fire the method “lastIndexOf()” on a JSfile object instead of a string.

So “fullPath” is a JSfile Object and not a String Object.
You can convert fullPath to String by doing:
var fullPathString = fullPath.getAbsolutePath()//this method can be found under file>JSFile
var lastSep = fullPathString.lastIndexOf(“/”);

You can always check what kind of Objects are returned, by checking the tooltip texts in the editor.