| View previous topic :: View next topic |
| Author |
Message |
guest3456 Guest
|
Posted: Thu Dec 17, 2009 9:47 am Post subject: if var=string not the same as if (var=string) |
|
|
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
|
Posted: Thu Dec 17, 2009 9:51 am Post subject: |
|
|
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 |
|
 |
guest3456 Guest
|
Posted: Thu Dec 17, 2009 9:56 am Post subject: |
|
|
i dont follow sir
how is my expression not TRUE? |
|
| Back to top |
|
 |
guest3456 Guest
|
Posted: Thu Dec 17, 2009 10:11 am Post subject: |
|
|
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
|
Posted: Thu Dec 17, 2009 10:16 am Post subject: |
|
|
| 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
|
Posted: Thu Dec 17, 2009 10:20 am Post subject: |
|
|
ahhh
ty sir, i will understand it now |
|
| Back to top |
|
 |
|