AutoHotkey Community

It is currently May 27th, 2012, 7:02 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: March 10th, 2006, 8:58 pm 
Offline

Joined: May 3rd, 2005, 1:05 pm
Posts: 44
Is it somehow possible to create a construct like the following
Code:
If (var = 1) or (var = 3)  or (var = 5)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 10th, 2006, 9:03 pm 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5347
Location: UK
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 10th, 2006, 9:14 pm 
Offline

Joined: May 3rd, 2005, 1:05 pm
Posts: 44
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???


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 10th, 2006, 9:22 pm 
Offline

Joined: August 24th, 2005, 5:17 pm
Posts: 1237
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 10th, 2006, 9:29 pm 
Offline

Joined: May 3rd, 2005, 1:05 pm
Posts: 44
no this also don't help


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 10th, 2006, 9:30 pm 
Within an expression everything which isn't a number and not tagged as a literal string, using ("") is treated as a variable.
AFAIK :)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 10th, 2006, 9:33 pm 
Code:
var=0
var1=1
var2=2
If (var <> var1) or (var <> var2)
   MsgBox % Var is: 0
Should work.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 10th, 2006, 10:01 pm 
Offline

Joined: May 3rd, 2005, 1:05 pm
Posts: 44
Thank you for your help. You was right, it was my fault, I had changed something different in between, so it was not working.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: March 11th, 2006, 6:32 am 
Offline

Joined: December 20th, 2005, 4:15 am
Posts: 165
Location: Malaysia
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)


Report this post
Top
 Profile  
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: Exabot [Bot], Google [Bot], migz99, sjc1000, Yahoo [Bot] and 80 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