MightyMalcolm Posted July 28, 2015 Share Posted July 28, 2015 (edited) Hello everyone^^I am somewhat new to AutoIt so please bear with me. I always thought that I was able to read, but neither helpfile nor internet search were able to explain the following behaviour to me:ConsoleWrite(StringInStr("hey<a>ho!", "<a>") & @CRLF) ConsoleWrite(StringInStr("hey<a>ho!", "<a>", Default, Default, Default) & @CRLF) ConsoleWrite(StringInStr("hey<a>ho!", "<a>", Default, Default, Default, Default) & @CRLF)The console output is400 My aim was to use the position parameter and so I did. Took me quite a while to find out what part of my code was causing the unexpected results. For now, I am working around this problem with the construction given in the helpfile: StringInStr(StringMid($string, $start), $substring), but this obviously isn't now how it's meant to be.Any help with this is greatly appreciated Edited July 28, 2015 by MightyMalcolm Link to comment Share on other sites More sharing options...
AspirinJunkie Posted July 28, 2015 Share Posted July 28, 2015 (edited) The default values for StringInStr aren't the "Default"-Keyword. They are Integer-values. So your'e Input will be implicitly casted to int. And Because "Int(Default) = 0" your input implicitly becomes: StringInStr("hey<a>ho!", "<a>", 0, 0, 0, 0)This leads to @error=1 because these are invalid values for "occurance" and "start".Have a look at the help file for Default:If used, the passed parameter will be set to the Default keyword and not to an optional parameter value, if defined.So if you only want to set the "start"-parameter this is the right syntax:StringInStr("hey<a>ho!", "<a>", 0, 1, $myStartValue) Edited July 28, 2015 by AspirinJunkie Link to comment Share on other sites More sharing options...
MightyMalcolm Posted July 28, 2015 Author Share Posted July 28, 2015 (edited) Dang! I tried replacing the Default-keyword for integers, just like you said, but it seems I never actually replaced ALL of them at the same time %) So much for thorough testing. My bad there.Cheers and thanks! Edited July 28, 2015 by MightyMalcolm 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