using indexof & substring
Posted on 2004-09-14
Here's the error I'm encountering:
Microsoft JScript runtime error '800a01b6'
Object doesn't support this property or method
blah blah blah at line 100
There is a variable called PathStr, which is a partial path/filename. An example of a possible value of PathStr is:
progressimages\7997-80720.13\255 KP - Aslab.JPG
I need to extract just the Filename without the extension. The code segment I've tried to use is:
// The next line is Line 100 where the error occurs.
var offset1 = PathStr.indexof("\");
var offset1 = PathStr.indexof(".jpg");
var Caption = PathStr.substring(offset1, offset2);
Using the PathStr example value given above, I believe I'd end up with "7997-80720.13\255 KP - Aslab", then I'd do it again to get down to just the filename.
But dammed if I can see what's wrong with the offset1 and offeset2 lines. Just a syntax error or am I on the wrong track completely?
Or maybe there is a better, simpler way altogether?