Jump to content
Sign in to follow this  
armyman

Select ... Case statement

Recommended Posts

armyman

Hello all,

I'm trying to write a Select ... Case statement that compares string values.

The code is pretty simple I'm just havng problems comparing the string values.

Select
Case $xyz = ""
    ;xyz values is blank
    ;does something
Case $xyz = 'abc' OR 'xyz'
    ;xyz value is either abc or xyz
    ;does something Else
Case Else
    ;xyz value is anything else

Thanks in advance

Share this post


Link to post
Share on other sites
bwochinski

The 2nd CASE statement needs to be written like below...

Select
Case $xyz = ""
    ;xyz value is empty
Case $xyz = 'abc' OR $xyz = 'xyz'
    ;xyz value is either abc or xyz
Case Else
    ;xyz value is anything else
EndSelect

Edited by bwochinski

Share this post


Link to post
Share on other sites
JohnOne

Maybe a Switch might be better.

Switch $xyz
Case ""
    ;xyz value is empty
Case 'abc', 'xyz'
    ;xyz value is either abc or xyz
Case Else
    ;xyz value is anything else
EndSwitch

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites
Bowmore

If you are comparing 1 value against several possible values, you could also use a switch statement.

Switch $xyz
  Case ""
    ;xyz value is empty
  Case 'abc' ,'xyz'
        ;xyz value is either abc or xyz
  Case Else
        ;xyz value is anything else
EndSwitch

Edit: John beat me to it

Edited by Bowmore

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Share this post


Link to post
Share on other sites
armyman

Thanks all,

I went ahead and used the switch statemnet.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.