Page 1 of 1

Multi-Line IF Statement ?

Posted: 18 Jan 2024, 22:24
by rc76
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
}

Re: Multi-Line IF Statement ?

Posted: 18 Jan 2024, 22:36
by flyingDman

Re: Multi-Line IF Statement ?

Posted: 18 Jan 2024, 22:41
by rc76
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
}

Re: Multi-Line IF Statement ?

Posted: 18 Jan 2024, 22:48
by flyingDman
Yes, though legibility may suffer...

Re: Multi-Line IF Statement ?

Posted: 18 Jan 2024, 23:56
by rc76
lol ...

Will flyingDman have any recommendation how to type out this IF conditions so legibility is better?

Re: Multi-Line IF Statement ?

Posted: 19 Jan 2024, 00:28
by Xtra
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
}