It's a decent suggestion, I'll add it to my list.
Edit: Has since been moved into the 'AutoIt Feature Requests (Possible)' subforum.
Edited by Koshy John, 12 January 2008 - 03:51 PM.
Posted 07 January 2008 - 02:44 PM
It's a decent suggestion, I'll add it to my list.
Edited by Koshy John, 12 January 2008 - 03:51 PM.
Posted 11 January 2008 - 11:47 PM
Allow me to translate what Jon said:It's a decent suggestion, I'll add it to my list.
Posted 12 January 2008 - 03:47 PM
Allow me to translate what Jon said:
"It's a decent suggestion, I'll add it to my list of things I'll do eventually but probably not get around to."
Posted 12 January 2008 - 04:46 PM
Posted 12 January 2008 - 04:50 PM
Posted 23 March 2008 - 03:34 PM
Posted 23 March 2008 - 06:06 PM
Posted 23 March 2008 - 10:29 PM
Cool about the "start", I'm sure the "limit" was for "end character position". Default being end of string, and "limit" being chars from start (Sort of a StringMid type I would suppose).It's still on my personal todo list, regardless of whether it's in trac.
I just reread the orginal post though, and I am baffled by the "limit" parameter - I just don't see why it's there.
"start" is simply the character position in the string to begin the search, yes? If so I can probably add that quickly.
Edit: I've done the "start" bit.
Edited by SmOke_N, 23 March 2008 - 10:30 PM.
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.
Posted 23 March 2008 - 11:50 PM
Global $sString1 = "abcdefghijklmnopqrstuvwxyz", $sString2 = "efghijkl" Global $bExam[4] $bExam[0] = _StringInStrEx($sString1, $sString2);Beginning to end search not case sensitive $bExam[1] = _StringInStrEx($sString1, $sString2, 0, 1, 5, -1);5 chars from beginning to end of string search $bExam[2] = _StringInStrEx($sString1, $sString2, 0, 1, 5, 8); 5 chars from beginning of string to 13 chars from beginning of string $bExam[3] = _StringInStrEx($sString1, $sString2, 0, 1, 6);start search from sixth char of string (should return 0/False as no match in this example) For $i = 0 To 3 If $bExam[$i] > 0 Then $bExam[$i] = 1 MsgBox(64, "bExam[" & $i & "]", ($bExam[$i] = 1)) Next Func _StringInStrEx($sString1, $sString2, $iCase = 0, $iOccurence = 1, $nStart = 1, $nEnd = -1) ;Do we only need a regular StringInStr func If ($nStart = 1 Or $nStart = Default) And ($nEnd = -1 Or $nEnd = Default) Then Return StringInStr($sString1, $sString2, $iCase, $iOccurence) EndIf ;Configure start/end expression Local $sEnd = "(.{" & $nEnd & "}).*?(?m:$)", $sStart = ".{" & ($nStart -1) & "}" If ($nEnd = Default Or $nEnd = -1) Then $sEnd = "(.*?)(?m:$)" If ($nStart = 1 Or $nStart = Default) Then $sStart = "^" ;Pull out start to end string for string one Local $aSRE = StringRegExp($sString1, "(?s)" & $sStart & $sEnd, 1) If IsArray($aSRE) = 0 Then Return SetError(1, 0, 0) Return StringInStr($aSRE[0], $sString2, $iCase, $iOccurence) EndFunc
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.
Posted 24 March 2008 - 04:01 AM
Edited by Koshy John, 24 March 2008 - 04:03 AM.
Posted 24 March 2008 - 04:11 AM
Edited by SmOke_N, 24 March 2008 - 04:16 AM.
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.
Posted 24 March 2008 - 04:31 AM
Posted 24 March 2008 - 10:00 AM
If I understand you correctly, you're saying "I have a string 100 character in length. I want to search for "ab" in the range 70 - 80 of this string." Okay, if that's what you want, then extract that character range with StringMid() and use StringInStr() on that shortened string. Why must StringInStr() do 100% of the work when there are other tools to share the work-load? I realize, your issue is performance. But we can't bloat up every function just for the sake of performance. I haven't looked at the implementation of StringInStr() but unless it's stupidly simple to add a limit parameter, IMO, you should be using StringMid() to pluck out the range and then StringInStr() on the new string.
Posted 24 March 2008 - 10:02 AM
I _think_ it's the same thing. The number of "chunks" is effectively the "length" which is effectively end-start.Sounds more like a chunk comparison to me then... guess I didn't really get it after all.
Edit for clarity:
I didn't understand the "limit/end" part, I was assuming it was characters after the starting position, not the number of chunks to loop through.
Posted 24 March 2008 - 10:09 AM
Not reallyIf it makes your work any easier, I can put up how I would implement it in C++ and you can just make changes as it suits you. I can also draft documentation for the help file.
Posted 24 March 2008 - 10:15 AM
Posted 24 March 2008 - 11:54 AM
Sleep(100) $time = TimerInit() For $i = 1 to 200000 StringInStr("supercalifragilisticexpialidocious", "viva", 0, 1) Next $time1diff = Round(TimerDiff($time) / 1000, 2) $time = TimerInit() For $i = 1 to 200000 StringInStr( StringMid("supercalifragilisticexpialidocious", 1, 4), "viva", 0, 1) Next $time2diff = Round(TimerDiff($time) / 1000, 2) $time = TimerInit() For $i = 1 to 200000 StringInStr("supercalifragilisticexpialidocious", "viva", 0, 1, 1, 4) Next $time3diff = Round(TimerDiff($time) / 1000, 2) $msg = "No limits: " & $time1diff & @LF $msg &= "StringMid: " & $time2diff & @LF $msg &= "Limits: " & $time3diff MsgBox(0, @AutoItVersion, $msg)
No limits: 1.51 StringMid: 0.8 Limits: 0.62
Posted 24 March 2008 - 12:50 PM
Posted 24 March 2008 - 01:31 PM
0.62 is only 40% of 1.51. That is quite a bang. So the new StringInStr against the old one, the new one wins hands down.The difference in performance is fairly small:
AutoItSleep(100) $time = TimerInit() For $i = 1 to 200000 StringInStr("supercalifragilisticexpialidocious", "viva", 0, 1) Next $time1diff = Round(TimerDiff($time) / 1000, 2) $time = TimerInit() For $i = 1 to 200000 StringInStr( StringMid("supercalifragilisticexpialidocious", 1, 4), "viva", 0, 1) Next $time2diff = Round(TimerDiff($time) / 1000, 2) $time = TimerInit() For $i = 1 to 200000 StringInStr("supercalifragilisticexpialidocious", "viva", 0, 1, 1, 4) Next $time3diff = Round(TimerDiff($time) / 1000, 2) $msg = "No limits: " & $time1diff & @LF $msg &= "StringMid: " & $time2diff & @LF $msg &= "Limits: " & $time3diff MsgBox(0, @AutoItVersion, $msg)
No limits: 1.51 StringMid: 0.8 Limits: 0.62
No limits: 2.23 StringMid: 1.59
No limits: 4.67 StringMid: 3.26
Edited by Koshy John, 24 March 2008 - 01:33 PM.
Posted 24 March 2008 - 03:32 PM
0 members, 0 guests, 0 anonymous users