Jump to content

if statement with 'IN' expression [SOLVED]

Recommended Posts


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

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.


Edited by Montfrooij
Link to post
Share on other sites

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

"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 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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...