Jump to content
Sign in to follow this  
Montfrooij

if statement with 'IN' expression [SOLVED]

Recommended Posts

Montfrooij

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
endif

Where 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' option

So 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 by Montfrooij

Share this post


Link to post
Share on other sites
Bowmore

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

Share this post


Link to post
Share on other sites
Montfrooij

That I did not know.

Thanks a lot!

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  

×