Sign in to follow this  
Followers 0
Cambunctious

How to use 'Or'

4 posts in this topic

Can someone give me a simple demo on how to use the 'Or' operator? I can never seem to get it to work for anything. For instance, I would like to code something like this:

Switch $var

Case 1

...

Case 2 Or 3

...

Case 4

...

EndSwitch

Am I doing something wrong here? Sorry for asking such a dumb question. >_<

Cambunctious

Share this post


Link to post
Share on other sites



Try:

Switch $var
    Case 1
        ConsoleWrite("1" & @CRLF)
    Case 2, 3
        ConsoleWrite("2 or 3" & @CRLF)
    Case 4
        ConsoleWrite("4" & @CRLF)
EndSwitch


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Jos gave you the example for the Switch statement that you used as an example (comma instead of OR) but if you had been using a Select statement it would have been

Select
    Case $Var = 1
        ConsoleWrite("1" & @CRLF)
    Case $Var = 2 OR $Var = 3
        ConsoleWrite("2 or 3" & @CRLF)
    Case $Var = 4
        ConsoleWrite("4" & @CRLF)
EndSelect

Another OR example would be

If @Sec <= 1 AND (@Min = 0 OR Mod(@Min, 15)= 0 ) Then
    ;; Perform some operation every 15 minutes
EndIf

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

I think that answers my question. Thanks!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0