AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

strings compare (solved!)

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
TestPilot



Joined: 26 Jun 2007
Posts: 52

PostPosted: Wed Mar 12, 2008 11:07 pm    Post subject: strings compare (solved!) Reply with quote

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
Code:
if %str1%=%str2%

Code:
if str1=str2

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
View user's profile Send private message
Rhys



Joined: 17 Apr 2007
Posts: 761
Location: Florida

PostPosted: Wed Mar 12, 2008 11:15 pm    Post subject: Reply with quote

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
View user's profile Send private message
BoBoĻ
Guest





PostPosted: Wed Mar 12, 2008 11:17 pm    Post subject: Reply with quote

Code:
If str1 = %str2%

Code:
If (str1 = str2)
Back to top
TestPilot



Joined: 26 Jun 2007
Posts: 52

PostPosted: Wed Mar 12, 2008 11:19 pm    Post subject: Reply with quote

Thank you very much - it works your way.

Duh, that %var% and just var and := and = are freaking confusing.
Back to top
View user's profile Send private message
TestPilot



Joined: 26 Jun 2007
Posts: 52

PostPosted: Wed Mar 12, 2008 11:21 pm    Post subject: Reply with quote

thank you both -

If (String1 = String2)

works perfectly!
Back to top
View user's profile Send private message
TestPilot



Joined: 26 Jun 2007
Posts: 52

PostPosted: Wed Mar 12, 2008 11:27 pm    Post subject: Reply with quote

Nah it is not working in cases where difference is only case of letters.
And I got
Code:
StringCaseSense, On
inside my script! Evil or Very Mad

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
View user's profile Send private message
BoBoĻ
Guest





PostPosted: Wed Mar 12, 2008 11:42 pm    Post subject: Reply with quote

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

PostPosted: Wed Mar 12, 2008 11:45 pm    Post subject: Reply with quote

Thank you - somehow
Code:
If str1 = %str2%
works case sensitive way.
Back to top
View user's profile Send private message
BoBoĻ
Guest





PostPosted: Wed Mar 12, 2008 11:57 pm    Post subject: Reply with quote

Code:
If (String1 == String2)
That too.
Back to top
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group