Zisly Posted August 29, 2008 Share Posted August 29, 2008 Well, I can't find anything which would count how many "x" words there is in a edit control.. Example: It will count how many "do" there is in the edit control.. If anyone knows how I could do this, please, post it! Thanks in advance, Zisly, Link to comment Share on other sites More sharing options...
Nahuel Posted August 29, 2008 Share Posted August 29, 2008 (edited) First you should read the whole text in the edit control: $text=GuiCtrlRead($edit) Then use StringSplit() to create an array with all the words the edit control has using " " as a separator: $words=StringSplit($text," ") in a loop, check how many times a given word repeats. $x=0 $myword="autoit" For $i=0 to $words[0] if $words[$i]=$myword then $x+=1 next Now $x has the number of times the word repeats in the text: MsgBox(0,"","The word " & $myword & " is " & $x & " times in the text") Note that I just wrote those lines and they might not work, but you get the idea. Edited August 29, 2008 by Nahuel Link to comment Share on other sites More sharing options...
Zisly Posted August 29, 2008 Author Share Posted August 29, 2008 Thanks for the fast reply! Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted August 29, 2008 Moderators Share Posted August 29, 2008 First you should read the whole text in the edit control: $text=GuiCtrlRead($edit) Then use StringSplit() to create an array with all the words the edit control has using " " as a separator: $words=StringSplit($text," ") in a loop, check how many times a given word repeats. $x=0 $myword="autoit" For $i=0 to $words[0] if $words[$i]=$myword then $x+=1 next Now $x has the number of times the word repeats in the text: MsgBox(0,"","The word " & $myword & " is " & $x & " times in the text") Note that I just wrote those lines and they might not work, but you get the idea.Wouldn't this be much easier? StringReplace($text, $myword, "") MsgBox(64, "Info", "Number of times word is in string = " & @Extended) Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Nahuel Posted August 29, 2008 Share Posted August 29, 2008 Dear ol' smoke... I must admit I missed you. Mr Zisly, do what the man says. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now