Spinner385 Posted July 28, 2012 Share Posted July 28, 2012 (edited) 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 July 28, 2012 by Spinner385 Link to comment Share on other sites More sharing options...
Spinner385 Posted July 28, 2012 Author Share Posted July 28, 2012 (edited) 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 FalseFinds 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 July 28, 2012 by Spinner385 Link to comment Share on other sites More sharing options...
Recommended Posts