Montfrooij Posted March 21, 2012 Share Posted March 21, 2012 (edited) Hi,I am trying to improve (shorten) my (sometimes) long 'if' statements that contain many 'or' expressions .if $nMsg = $inpFilOms or $nMsg = $inpFilCycl or $nMsg = $inpFilDatV or $nMsg = $inpFilDatT or $nMsg = $inpFilGekop then ;do something endifWhere the $nMsg is every time the same 'left' part of the expression and the action that will follow is also the same .I am used to work with SQL syntax and there we have the 'IN' optionSo that would be something like CASE WHEN $nMsg IN ($inpFilOms, $inpFilCycl,$inpFilDatV,$inpFilDatT,$inpFilGekop) then ....Is there any way to achieve this in AutoIT?It would make my statements somewhat shorter.Thanks in advance.Peter Edited March 21, 2012 by Montfrooij Link to comment Share on other sites More sharing options...
Bowmore Posted March 21, 2012 Share Posted March 21, 2012 You can get similar functionality by using a switch statement Switch $nMsg case $inpFilOms,$inpFilCycl,$inpFilDatV,$inpFilDatT,$inpFilGekop ;do something case $otheropt ;do something case else ;do something else endswitch "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 Link to comment Share on other sites More sharing options...
Montfrooij Posted March 21, 2012 Author Share Posted March 21, 2012 That I did not know. Thanks a lot! 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