AutoHotkey Community

It is currently May 26th, 2012, 4:27 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: March 13th, 2008, 12:07 am 
Offline

Joined: June 26th, 2007, 7:43 am
Posts: 52
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 March 13th, 2008, 12:46 am, edited 2 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 13th, 2008, 12:15 am 
Offline

Joined: April 17th, 2007, 1:37 pm
Posts: 761
Location: Florida
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!]
Image


Last edited by Rhys on March 13th, 2008, 12:20 am, edited 3 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 13th, 2008, 12:17 am 
Code:
If str1 = %str2%

Code:
If (str1 = str2)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 13th, 2008, 12:19 am 
Offline

Joined: June 26th, 2007, 7:43 am
Posts: 52
Thank you very much - it works your way.

Duh, that %var% and just var and := and = are freaking confusing.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 13th, 2008, 12:21 am 
Offline

Joined: June 26th, 2007, 7:43 am
Posts: 52
thank you both -

If (String1 = String2)

works perfectly!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 13th, 2008, 12:27 am 
Offline

Joined: June 26th, 2007, 7:43 am
Posts: 52
Nah it is not working in cases where difference is only case of letters.
And I got
Code:
StringCaseSense, On
inside my script! :evil:

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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 13th, 2008, 12:42 am 
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.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 13th, 2008, 12:45 am 
Offline

Joined: June 26th, 2007, 7:43 am
Posts: 52
Thank you - somehow
Code:
If str1 = %str2%
works case sensitive way.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 13th, 2008, 12:57 am 
Code:
If (String1 == String2)
That too.


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], Exabot [Bot], LazyMan, oldbrother and 8 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group