The Daily Click ::. Forums ::. Klik Coding Help ::. Help with special obj. "find" function
 

Post Reply  Post Oekaki 
 

Posted By Message

aphant



Registered
  18/05/2008
Points
  1242
26th September, 2009 at 15:25:44 -

Find("source string","string",????)


Where ???? is:
"MMF DOESN'T KNOW WTF IT WANTS FOR AN ALPHANUMERIC EXPRESSION."


I'm trying to see if "string" can be found in "source string" without the use of an extension. The special object has a string function called "Find string in string", which SOUNDS like it's what I want. Problem is that it refuses to work. Help with this would be much appreciated.

 

OMC

What a goofball

Registered
  21/05/2007
Points
  3516

KlikCast Musician! Guy with a HatSomewhat CrazyARGH SignLikes TDCHas Donated, Thank You!Retired Admin
26th September, 2009 at 15:49:51 -

If I remember right it wants a 1 there. Could be a 0. Not sure. O_o

 

  		
  		

aphant



Registered
  18/05/2008
Points
  1242
26th September, 2009 at 15:57:08 -

I tried all integers from -10 to 10, no dice.

 

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
26th September, 2009 at 16:07:31 -

"Find String in String returns the 0-based index of a sub-string in the string. Parameters = string to look into, sub-string to look for and index of the first character to start the search from. Returns -1 if the sub-string is not found in the string."

So yes, the third value should be a "0".

What *exactly* are you trying to do?


 
n/a

nim



Registered
  17/05/2002
Points
  7233
26th September, 2009 at 16:16:11 -

This has always been flakey for me too. I think you need to loop through each character in the string you're evaluating as a starting point for the search (stupid, I know)

 
//

MrMcFlurry



Registered
  03/08/2009
Points
  89

360 Owner
26th September, 2009 at 16:49:55 -

No, it's simply that the item returns a number, basically,if you set a counter to

Find("source string","string",0)
index:01234567...


The counter will be set to 7
If there is no occurrence of the word, it returns -1. so if result >=0, it's there, else, it isn't.

Edited by MrMcFlurry

 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
26th September, 2009 at 16:53:33 -

Correct. There's no need for fastlooping or anything like that.

 
n/a

MrMcFlurry



Registered
  03/08/2009
Points
  89

360 Owner
26th September, 2009 at 17:05:15 -

here, took 5 mins to knock up an example of how it works
http://www.mediafire.com/download.php?ki0nm1n3d33

 
n/a

aphant



Registered
  18/05/2008
Points
  1242
26th September, 2009 at 17:44:50 -

If the third value is supposed to be a 0, then I do not see why there is any reason to have you give a value. Regardless, when I tried 0 it kept giving the error, "Please enter alphanumeric blah blah" in the expression editor.

Now I can replicate the string parse object and create delimited text! Woot, thanks everyone for the assistance.

 

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
26th September, 2009 at 18:04:44 -

Originally Posted by Adam Phant
If the third value is supposed to be a 0, then I do not see why there is any reason to have you give a value.

It's incase the substring occurs more than once in the main string.
You set it to "0" to find the first occurence,
Then set it to the value returned +1, to find the next occurence,
Then repeat until "-1" is returned, meaning there are no more occurences.

Just using the String Parser extension is probably easier though...

 
n/a

MrMcFlurry



Registered
  03/08/2009
Points
  89

360 Owner
27th September, 2009 at 00:18:35 -

well i have a pretty straightforward example uploaded there a couple posts back, please ask if you have any questions.

Find("source string","string",0)

that will work, but remember, the result will be a number. you can set a counter to it's result, but not a string, for example, as a string will expect text. In the example I upload, I'm setting a counter object to
Find(contents of editbox1, contents of editbox2, 0)
searching for contents of editbox2, inside editbox1 from the first letter in the source.


to expand on what sketch said about multiple strings, say your source string is:

"This string is a string with many strings in it."

and the search is "string"

string occurs at 5 letters, 17 letters and 34 letters in.

now keeping in mind, the 3rd variable is how many characters into the source to start the search form, 0 being the start of the string

running with 'Find(source, search ,0)' will return the number 5, the beginning of the first string.

if you then search for 6 (location of first string+1) : 'Find(source, search ,6)' will return 17

if you then search for 18 (location of second string+1) : 'Find(source, search ,18 )' will return 34

so using a loop like this, you can find every instance of the search in a string.



Edit:
A simple pseudo code would be:

*Compare two general values: Find("source string", "string",0) 'is greater or equal to' 0
- do actions

This will 'do actions' if "string" exists in "source string"

Edited by MrMcFlurry

 
n/a
   

Post Reply



 



Advertisement

Worth A Click