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 (expression) or (expression) or (expression) ?

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



Joined: 03 May 2005
Posts: 44

PostPosted: Fri Mar 10, 2006 7:58 pm    Post subject: If (expression) or (expression) or (expression) ? Reply with quote

Is it somehow possible to create a construct like the following
Code:
If (var = 1) or (var = 3)  or (var = 5)
Back to top
View user's profile Send private message
polyethene



Joined: 11 Aug 2004
Posts: 5248
Location: UK

PostPosted: Fri Mar 10, 2006 8:03 pm    Post subject: Reply with quote

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%

_________________
GitHubScriptsIronAHK Contact by email not private message.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
bob3150



Joined: 03 May 2005
Posts: 44

PostPosted: Fri Mar 10, 2006 8:14 pm    Post subject: Reply with quote

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



Joined: 24 Aug 2005
Posts: 1237

PostPosted: Fri Mar 10, 2006 8:22 pm    Post subject: Reply with quote

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



Joined: 03 May 2005
Posts: 44

PostPosted: Fri Mar 10, 2006 8:29 pm    Post subject: Reply with quote

no this also don't help
Back to top
View user's profile Send private message
BoBo
Guest





PostPosted: Fri Mar 10, 2006 8:30 pm    Post subject: Reply with quote

Within an expression everything which isn't a number and not tagged as a literal string, using ("") is treated as a variable.
AFAIK Smile
Back to top
BoBo
Guest





PostPosted: Fri Mar 10, 2006 8:33 pm    Post subject: Reply with quote

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

PostPosted: Fri Mar 10, 2006 9:01 pm    Post subject: Reply with quote

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



Joined: 20 Dec 2005
Posts: 165
Location: Malaysia

PostPosted: Sat Mar 11, 2006 5:32 am    Post subject: Re: If (expression) or (expression) or (expression) ? Reply with quote

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