How do I access the returned value from this command

Discussions concerning programming of SOFTIMAGE©
User avatar
Pete
Posts: 118
Joined: 16 Jun 2009, 07:28

How do I access the returned value from this command

Post by Pete » 05 Sep 2013, 06:56

Hi there,

Sorry to have to ask such a stupid question but in this example -

Code: Select all

// Returns 1
Application.LogMessage( StringSearch( "foo", "o" ) ) ;
how do i access the return value. I'm trying to check for a match in the string but I just can't seem to get anything to work.

Thanks
Pete

User avatar
myara
Posts: 406
Joined: 28 Sep 2011, 08:33

Re: How do I access the returned value from this command

Post by myara » 05 Sep 2013, 07:01

I'm not sure what is "StringSearch", or foo, or o, or "Returns 1", but it seems you are using JScript. If you want to search something in a string in JS you can use search or indexOf. You also have lastIndexOf.

Code: Select all

var string = "This is a test"
var search_test = string.search("test")
var indexof_test = string.indexOf("test")
M.Yara
Character Modeler | Softimage Generalist (sort of)

User avatar
Pete
Posts: 118
Joined: 16 Jun 2009, 07:28

Re: How do I access the returned value from this command

Post by Pete » 05 Sep 2013, 07:15

Thanks myara! Works great :)