| View previous topic :: View next topic |
| Author |
Message |
TestPilot
Joined: 26 Jun 2007 Posts: 52
|
Posted: Wed Mar 12, 2008 11:07 pm Post subject: strings compare (solved!) |
|
|
| Code: |
if %str1%==%str2%
str1 = Yess!!!
else
str1 = not again...
|
I wanna compare str1 and str2. And it always false. So else command executing. I was trying
but no luck. And strings are actually identical, on most test cases.
Last edited by TestPilot on Wed Mar 12, 2008 11:46 pm; edited 2 times in total |
|
| Back to top |
|
 |
Rhys
Joined: 17 Apr 2007 Posts: 761 Location: Florida
|
Posted: Wed Mar 12, 2008 11:15 pm Post subject: |
|
|
Try | Code: | String1=Text
String2=Text
GoSub, Test ;Should evaluate true
String2=Toast
GoSub, Test ;Should evaluate false
Return
Test:
If (String1 = String2) ;Functions assume you give them variable names (no % needed)
MsgBox WooHoo!
Else
MsgBox BooHoo!
Return |
_________________ [Join IRC!]

Last edited by Rhys on Wed Mar 12, 2008 11:20 pm; edited 3 times in total |
|
| Back to top |
|
 |
BoBoĻ Guest
|
Posted: Wed Mar 12, 2008 11:17 pm Post subject: |
|
|
|
|
| Back to top |
|
 |
TestPilot
Joined: 26 Jun 2007 Posts: 52
|
Posted: Wed Mar 12, 2008 11:19 pm Post subject: |
|
|
Thank you very much - it works your way.
Duh, that %var% and just var and := and = are freaking confusing. |
|
| Back to top |
|
 |
TestPilot
Joined: 26 Jun 2007 Posts: 52
|
Posted: Wed Mar 12, 2008 11:21 pm Post subject: |
|
|
thank you both -
If (String1 = String2)
works perfectly! |
|
| Back to top |
|
 |
TestPilot
Joined: 26 Jun 2007 Posts: 52
|
Posted: Wed Mar 12, 2008 11:27 pm Post subject: |
|
|
Nah it is not working in cases where difference is only case of letters.
And I got | Code: | | StringCaseSense, On | inside my script!
| Code: |
String1=Text
String2=tEXT
GoSub, Test ;Should evaluate false, for me "Test"<>"tEST" but If claim strings are identical:(
Test:
If (String1 = String2)
MsgBox babah
Else
MsgBox boobah
Return |
|
|
| Back to top |
|
 |
BoBoĻ Guest
|
Posted: Wed Mar 12, 2008 11:42 pm Post subject: |
|
|
Do yourself a favour and save the time you need to post - to check the manual for the additional information which is linked within the text, eg ...
StringCaseSense --> Expression comparison operators -->
| Quote: | | Equal (=) , case-sensitive-equal (==) , and not-equal (<> or !=). The operators != and <> are identical in function. The == operator behaves identically to = except when either of the inputs is not a number, in which case == is always case sensitive and = is always case insensitive (the method of insensitivity depends on StringCaseSense). By contrast, <> and != obey StringCaseSense. Note: A quoted literal string such as "55" is always considered non-numeric in this context. |
|
|
| Back to top |
|
 |
TestPilot
Joined: 26 Jun 2007 Posts: 52
|
Posted: Wed Mar 12, 2008 11:45 pm Post subject: |
|
|
| Thank you - somehow works case sensitive way. |
|
| Back to top |
|
 |
BoBoĻ Guest
|
Posted: Wed Mar 12, 2008 11:57 pm Post subject: |
|
|
| Code: | | If (String1 == String2) | That too. |
|
| Back to top |
|
 |
|