| View previous topic :: View next topic |
| Author |
Message |
bob3150
Joined: 03 May 2005 Posts: 44
|
Posted: Fri Mar 10, 2006 7:58 pm Post subject: If (expression) or (expression) or (expression) ? |
|
|
Is it somehow possible to create a construct like the following
| Code: | | If (var = 1) or (var = 3) or (var = 5) |
|
|
| Back to top |
|
 |
polyethene
Joined: 11 Aug 2004 Posts: 5248 Location: UK
|
Posted: Fri Mar 10, 2006 8:03 pm Post subject: |
|
|
That is possible, I've just tried it.
Example: | Code: | InputBox, var, Expressions, Value of 'var':, , , , , , , , 3
If (var = 1) or (var = 3) or (var = 5)
MsgBox, 'var' = %var% |
_________________ GitHub • Scripts • IronAHK • Contact by email not private message. |
|
| Back to top |
|
 |
bob3150
Joined: 03 May 2005 Posts: 44
|
Posted: Fri Mar 10, 2006 8:14 pm Post subject: |
|
|
And how is the correct syntax for that
| Code: | If (var <> %var1%) or (var <> %var2%)
{} |
is not working
| Code: | If var <> %var1%
{}
If var <> %var2%
{} |
is working.
In the seconed variant I always get the error that there are illigal characters in the variable name and it shows me the content of the variable??? |
|
| Back to top |
|
 |
evl
Joined: 24 Aug 2005 Posts: 1237
|
Posted: Fri Mar 10, 2006 8:22 pm Post subject: |
|
|
| Because everything inside the brackets in that syntax is treated as a variable - you don't want those % signs around the 2nd variable I suspect. |
|
| Back to top |
|
 |
bob3150
Joined: 03 May 2005 Posts: 44
|
Posted: Fri Mar 10, 2006 8:29 pm Post subject: |
|
|
| no this also don't help |
|
| Back to top |
|
 |
BoBo Guest
|
Posted: Fri Mar 10, 2006 8:30 pm Post subject: |
|
|
Within an expression everything which isn't a number and not tagged as a literal string, using ("") is treated as a variable.
AFAIK  |
|
| Back to top |
|
 |
BoBo Guest
|
Posted: Fri Mar 10, 2006 8:33 pm Post subject: |
|
|
| Code: | var=0
var1=1
var2=2
If (var <> var1) or (var <> var2)
MsgBox % Var is: 0 | Should work. |
|
| Back to top |
|
 |
bob3150
Joined: 03 May 2005 Posts: 44
|
Posted: Fri Mar 10, 2006 9:01 pm Post subject: |
|
|
| Thank you for your help. You was right, it was my fault, I had changed something different in between, so it was not working. |
|
| Back to top |
|
 |
Lemming
Joined: 20 Dec 2005 Posts: 165 Location: Malaysia
|
Posted: Sat Mar 11, 2006 5:32 am Post subject: Re: If (expression) or (expression) or (expression) ? |
|
|
You could use the if var in matchlist method:
| Code: | if var in 1,3,5
MsgBox The var is one, three, or five.
|
However, note that it compares the values as strings, not numbers. So 1.0 would not be the same as 1.
| bob3150 wrote: | Is it somehow possible to create a construct like the following
| Code: | | If (var = 1) or (var = 3) or (var = 5) |
|
|
|
| Back to top |
|
 |
|