Jump to content

Is StringUtil.Find borken?


Spinner385

Recommended Posts

Can anyone confirm if StringUtil.Find is working or not. I saw that it is red in the wiki page with no link to it. Then I tried this script with no success.

 

Event OnPlayerLoadGame()

string myString = "My Test String"
Debug.messagebox("The Find Index of Test in " + myString + " is " + StringUtil.Find(myString,"Test",0)

Endevent

 

I tried:

StringUtil.Find("Test",myString,0)

StringUtil.Find(myString,"Test",1)

StringUtil.Find("Test",myString,1)

the result is always -1.

Edited by Spinner385
Link to comment
Share on other sites

Oh well just wrote my own Find function. Someone may find it useful so here it is:

 

Bool Function FindInString(string LookFor, string LookIn)
int count1 = 0
int count2 = 0

While count1 < stringUtil.GetLength(LookIn)
If stringUtil.getNthChar(LookIn,count1) == stringUtil.getNthChar(LookFor,count2)
count2 += 1
endif
count1 += 1
If count2 == stringUtil.getLength(LookFor)
Return True
endif
endwhile
Return False
EndFunction

 

Returns True or False

Finds if the string LookIn contains the string LookFor in sequential order but not consecutively.

If your looking for the string "id" it will return True for "bid" or "triggered" but not "dig"

Edited by Spinner385
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...