mbunds Posted August 18, 2008 Share Posted August 18, 2008 I have searched the forums for an answer to this with no luck. What is the functional difference between the "Switch" and the "Select" keywords for responding to Case, and when would a programmer choose to use one over the other? Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 18, 2008 Share Posted August 18, 2008 I have searched the forums for an answer to this with no luck. What is the functional difference between the "Switch" and the "Select" keywords for responding to Case, and when would a programmer choose to use one over the other?Switch is for when all the cases are based on a single value (the one passed on the same line with the Switch keyword). All the Case statements (like "Case 1" or "Case > 10") are in reference to that one value.Select can use completely unrelated statements for each case (like "Case $n = 1" and "Case $x > 10") Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Triblade Posted August 18, 2008 Share Posted August 18, 2008 (edited) With Switch you only have to define the expression once. With Select you have to do it every Case.And as far as I can see, only Switch can do $var TO $var2<value> To <value> The case is executed if the expression is between the two values.But then again only Select, accouring to the help, seems the be the only one able to do:The expression can contain the boolean operators of AND, OR, and NOT as well as the logical operators <, <=, >, >=, =, ==, and <> grouped with parentheses as needed.Edit: Darn, If I hadn't push 'back' by accident I had beaten PsaltyDS... ^^ Edited August 18, 2008 by Triblade Leendert-Jan 1 My active project(s): A-maze-ing generator (generates a maze) My archived project(s): Pong3 (Multi-pinger) Link to comment Share on other sites More sharing options...
mbunds Posted August 18, 2008 Author Share Posted August 18, 2008 Switch is for when all the cases are based on a single value (the one passed on the same line with the Switch keyword). All the Case statements (like "Case 1" or "Case > 10") are in reference to that one value.Select can use completely unrelated statements for each case (like "Case $n = 1" and "Case $x > 10") Thank you kindly for the quick and concise answer! Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 18, 2008 Share Posted August 18, 2008 Edit: Darn, If I hadn't push 'back' by accident I had beaten PsaltyDS... ^^BWAAAHAHAHAHA! Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
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