Added in 1.8.10

/if (condition) <command>
/if ((condition) combiner (condition)) <command>
/if (condition operator condition) <command>
/if (condition) { <command> | command }

Conditional execution of code in a script or alias. Can also be used with /else and/or /elseif
Fills $v1 with either the condition-term value or the first of 2 conditions-terms, and fills $v2 with the value of the 2nd condition or with $null if there was only 1 condition. ($ifmatch is equivalent to $v1). When there are multiple groups of evaluated terms
While syntax is forgiving of non-use of parenthesis, it's probably best to use optional parenthesis around terms to improve readability, and in some cases ensures the correct values are filled into $v1 and $v2.


if ( $asctime($ctime,ddd) == Fri) echo -a today is Friday!

//if ( (1 > 2) || (4 > 3)) echo -a match $v1 > $v2
fills $v1 with 4 and $v2 with 3 because those were the term1 and term2 in the 'true' condition causing the command to execute. If the 1 were changed to another number greater than 2, then $v2 would be filled with 2 and $v1 filled with the replacement for 1.

|| = logical OR (if either condition is true) && = logical AND (only if both conditions are true)

//if ($rand(1,2) == 2) echo -a message1 displays only if random is 2 | echo -a message2 always displays
//var %a 1 | if (%a) { echo -a message 1 says % $+ a does not contain number equivalent to 0 or $false or $ $+ null | echo -a message 2 }
By enclosing within braces, can have 2+ commands executed only in the 'true' condition.
You can negate the logic using the ! symbol: //if (!$query(0)) echo -a there are no query windows open

Using /else or /elseif can be on the same line separated by the pipe symbol or on a new line:
//var %a $rand(1,10) | if (%a > 5) echo -a roll is 6-10 | else echo -a roll is 1-5

//var %a $rand(1,10) | if (%a > 5) echo -a roll is 6-10
elseif (%a isnum 4-5) echo -a roll is 4 or 5
else echo -a roll is 1-3