Akshay07 Posted January 30, 2010 Posted January 30, 2010 (edited) Hello all I am trying to use _StringBetween. If I read the help: #Include <String.au3> _StringBetween($s_String, $s_Start, $s_End [, $v_Case = -1]) Parameters $s_String The string to search. $s_Start The beginning of the string to find. Passing a blank string starts at the beginning $s_End The end of the string to find. Passing a blank string searches from $s_Start to end I tried this: $abc= "123.45" $test = _StringBetween($abc, " ", ".") MsgBox(0, "", $test ) I was expecting to have test="123" but the MsgBox is showing 0. I am sure I am misunderstanding something, I just need to be told what I am misunderstanding Thanks! Edited January 30, 2010 by Akshay07
whim Posted January 30, 2010 Posted January 30, 2010 Gave it a try, and it seems you need to pass an empty rather than a blank string ! Also, note that it returns an array $abc= "123.45" $test = _StringBetween($abc, "", ".") MsgBox(0, "", $test[0] ) this returned 123 for me whim
AdmiralAlkex Posted January 30, 2010 Posted January 30, 2010 Two things wrong there. _IsBetween returns an array, and you ask it to search for a space, which the string doesn't have. You would either want a blank string ("") or you could use Int() if it's just numbers. #Include <String.au3> $abc = "123.45" $test = _StringBetween($abc, "", ".") If IsArray($test) Then MsgBox(0, "", $test[0]) EndIf $test2 = Int($abc) MsgBox(0, "", $test2) .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
somdcomputerguy Posted January 30, 2010 Posted January 30, 2010 (edited) The code I tried first is identical to post #2, I'm not running the most recent version of AutoIt (currently I'm running 3.3.0.0), is that why that code returns an error "Subscript used with non-Array variable", I know that the function is returning a 0. However, I can successfully run this code and get "123" $abc= "123.45" $var = StringMid($abc, 1, 1) $test = _StringBetween($abc, $var, ".") MsgBox(0, "", $var & $test[0] ) Edit: Ya, I've answered my question. I upgraded to 3.3.4.0 and code identical to post #2 returns "123" instead of the error.. Edited January 31, 2010 by snowmaker - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change.
Akshay07 Posted January 30, 2010 Author Posted January 30, 2010 (edited) Gave it a try, and it seems you need to pass an empty rather than a blank string ! Also, note that it returns an array $abc= "123.45" $test = _StringBetween($abc, "", ".") MsgBox(0, "", $test[0] ) this returned 123 for me whim It does return 123 for me as well, thanks! The "help" is a bit confusing as it is mentioning a blank string. "Empty string" would be more relevant in my opinion Edit: I am guilty, I missed the part in the help that states "Success: A 0 based $array[0] contains the first found string. " My bad. Edited January 30, 2010 by Akshay07
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