Sign in to follow this  
Followers 0
armyman

Select ... Case statement

5 posts in this topic

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



#2 ·  Posted (edited)

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

#4 ·  Posted (edited)

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

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  
Followers 0