Multi-Line IF Statement ?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
rc76
Posts: 150
Joined: 07 Nov 2020, 01:45

Multi-Line IF Statement ?

18 Jan 2024, 22:24

A quick question around the "If" statement.

Is it possible to do a multi-line IF statement, if there are many conditions, such as:

Code: Select all

if (currentTime_day = "Mon" or currentTime_day = "Tue" or currentTime_day = "Wed") 
    and 
    (currentTime > "14:00" and currentTime < "16:00")
{
    ; than do xxx
}
rc76
Posts: 150
Joined: 07 Nov 2020, 01:45

Re: Multi-Line IF Statement ?

18 Jan 2024, 22:41

Awesome, thank you so much flyingDman

so it has to start with an operator, so be like:

Code: Select all

if (currentTime_day = "Mon" or currentTime_day = "Tue" or currentTime_day = "Wed") 
    and (currentTime > "14:00" and currentTime < "16:00")
{
    ; than do xxx
}
User avatar
flyingDman
Posts: 2832
Joined: 29 Sep 2013, 19:01

Re: Multi-Line IF Statement ?

18 Jan 2024, 22:48

Yes, though legibility may suffer...
14.3 & 1.3.7
rc76
Posts: 150
Joined: 07 Nov 2020, 01:45

Re: Multi-Line IF Statement ?

18 Jan 2024, 23:56

lol ...

Will flyingDman have any recommendation how to type out this IF conditions so legibility is better?
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: Multi-Line IF Statement ?

19 Jan 2024, 00:28

This may be more readable:

Code: Select all

if InStr("Mon|Tue|Wed", currentTime_day) and (currentTime > "14:00" and currentTime < "16:00")
{
    ; than do xxx
}

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 200 guests