Sign in to follow this  
Followers 0
Justforfun

Multi comparing

5 posts in this topic

Quick question can't seem to find the answer and the help file does not discuss it much.

Using the boolean operators can you do something like this.

I want to compare a answer but I need to compare it to multiple arrays Example if the answer lands in these areas 1000-2000, 6000-7000, 8000-9000, and 12000 - 13000 I want it to do a function is there away to check this with out having to write

If $Answer > 1000 Then 
If $answer < 2000 Then
; " Function here "
Endif
Endif

Over and over, is there a easier way to check all areas then do function.

Sorry about the rambling hope you understand what I am trying to say.

Share this post


Link to post
Share on other sites



Perhaps you want to try a switch/case control statement?

Share this post


Link to post
Share on other sites

Perhaps you want to try a switch/case control statement?

Can you give a example?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Dim $aVal[5] = [950, 1298, 1563, 2209, -1]

FOR $Answer In $aVal
    Switch $Answer
        Case 0 To 1000
            MsgBox(4096, "Result", $Answer & " <= 1000")
        Case 1001 To 1999
            MsgBox(4096, "Result", $Answer & " is greater than 1000 and less than 2000")
        Case Else
            MsgBox(4096, "Result", $Answer & " is less than 0 or >= 2000")
    EndSwitch
Next

EDIT: Improved the example

Edited by GEOSoft

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

Oh thanks for the example but I got it, I used my Brain.exe and viewed the help file for the case, switch controls. Thanks guys/gals.

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