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 

if var=string not the same as if (var=string)

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





PostPosted: Thu Dec 17, 2009 9:47 am    Post subject: if var=string not the same as if (var=string) Reply with quote

i can't understand why this is happening

Code:

  Loop, Parse, mylist, `,
  {
    if move = hello
      msgbox zxzcvzxvcz
    if (move = hello) {
      msgbox qwerqwer
      ;more code..
  }


why am i only seeing the first msgbox?
Back to top
UncleScrooge



Joined: 14 Apr 2009
Posts: 75
Location: Italy

PostPosted: Thu Dec 17, 2009 9:51 am    Post subject: Reply with quote

because that's how the "IF (expression)" command syntax works..
you should en-close the expression in parenthesis (or round brackets, however you wanna call 'em) unless...
look here
_________________
Intel Centrino @ 2.8GHz
4 GB RAM
WIN XP SP3
Back to top
View user's profile Send private message AIM Address
guest3456
Guest





PostPosted: Thu Dec 17, 2009 9:56 am    Post subject: Reply with quote

i dont follow sir

how is my expression not TRUE?
Back to top
guest3456
Guest





PostPosted: Thu Dec 17, 2009 10:11 am    Post subject: Reply with quote

ok the problem is how i'm assigning the variable

apparently quotes throw everything off

can someone explain this to me? i'm using the assignment operator
http://www.autohotkey.com/docs/commands/SetExpression.htm

Code:


ss := "hi"

f1::
  msgbox %hi%     ; hi as expected
  if ss=hi
    msgbox this works
  if (ss=hi)
    msgbox this doesnt
return



Code:

ss := hi

f1::
  msgbox %hi%     ; empty wtf
  if ss=hi
    msgbox this doesnt
  if (ss=hi)
    msgbox this works
return



whats going on here? what is getting stored in the 2nd example?
Back to top
angly
Guest





PostPosted: Thu Dec 17, 2009 10:16 am    Post subject: Reply with quote

guest3456 wrote:
i dont follow sir

how is my expression not TRUE?

No, it is not.
Code:
  Loop, Parse, mylist, `,
  {
    if move = hello
      msgbox zxzcvzxvcz
    if (move = "hello") { ; notice the quotes around LITERAL TEXT IN AN EPRESSION
      msgbox qwerqwer
      ;more code..
  }

An explanation and many examples are provided here: AutoHotkey Expression Examples: "" %% () and all that . Section H expressly applies to your mis-understanding.
Back to top
guest3456
Guest





PostPosted: Thu Dec 17, 2009 10:20 am    Post subject: Reply with quote

ahhh
ty sir, i will understand it now
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