Sign in to follow this  
Followers 0
failedtocompile

Help with multiple If statements

3 posts in this topic

#1 ·  Posted (edited)

Hello Guys

I'm new to Autoit

I was wondering if there is a way to have multiple "If" statements grouped together. Or is there a cleaner and or simpler way using

$var = $ProcessName1|$ProcessName2|$ProcessName3

If you could enlighten me in the right terminology that would be great

e.g. (code below doesn't work with having multiple if statements within my script)

$ProcessName1 = ""
$ProcessName2 = ""
$ProcessName3 = ""
Case $Btn_1
            If ProcessExists($ProcessName1) Then
                MsgBox(0, "?? is Running", $ProcessName1 & "   etc......")
Else
If ProcessExists($ProcessName2) then
MsgBox(0, "?? is Running", $ProcessName2 & "   etc......")
Else
If ProcessExists($ProcessName3) then
MsgBox(0, "?? is Running", $ProcessName3 & "   etc......")

Else
Runwait()
EndIf

Case $btn_2
            If ProcessExists($ProcessName1) Then
                MsgBox(0, "?? is Running", $ProcessName1 & "   etc......")
Else
If ProcessExists($ProcessName2) then
MsgBox(0, "?? is Running", $ProcessName2 & "   etc......")
Else
If ProcessExists($ProcessName3) then
MsgBox(0, "?? is Running", $ProcessName3 & "   etc......")
Else
Runwait()
EndIf

Thanks in advance

Edited by failedtocompile

Share this post


Link to post
Share on other sites



The correct syntax is:

If ..... Then
....
ElseIf..... Then
.....
Else
.....
EndIf

On your code:

If ProcessExists($ProcessName1) Then
    MsgBox(0, "?? is Running", $ProcessName1 & "   etc......")
ElseIf ProcessExists($ProcessName2) then
    MsgBox(0, "?? is Running", $ProcessName2 & "   etc......")
ElseIf ProcessExists($ProcessName3) then
    MsgBox(0, "?? is Running", $ProcessName3 & "   etc......")
Else
    Runwait()
EndIf

When the words fail... music speaks

Share this post


Link to post
Share on other sites

The correct syntax is:

If ..... Then
....
ElseIf..... Then
.....
Else
.....
EndIf

On your code:

If ProcessExists($ProcessName1) Then
    MsgBox(0, "?? is Running", $ProcessName1 & "   etc......")
ElseIf ProcessExists($ProcessName2) then
    MsgBox(0, "?? is Running", $ProcessName2 & "   etc......")
ElseIf ProcessExists($ProcessName3) then
    MsgBox(0, "?? is Running", $ProcessName3 & "   etc......")
Else
    Runwait()
EndIf

Awesome thanks very much Andreik this has worked :)

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  
Followers 0