armyman Posted March 22, 2011 Posted March 22, 2011 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
bwochinski Posted March 22, 2011 Posted March 22, 2011 (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 March 22, 2011 by bwochinski
JohnOne Posted March 22, 2011 Posted March 22, 2011 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.
Bowmore Posted March 22, 2011 Posted March 22, 2011 (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 March 22, 2011 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
armyman Posted March 22, 2011 Author Posted March 22, 2011 Thanks all, I went ahead and used the switch statemnet.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now