alias iftest {
;Next line echos "hello world" because the left and right sides
;of the if statement are assigned to $v1 and $v2, respectively
if (hello != world) echo -a $v1 $v2
;Next couple of lines echo "hello pie" and "hello cheesecake"
;This shows two things: first that $v1 and $v2 work with $iif
;It also shows that they keep their value after the $iif, and
;do not go back to whatever if statement they are in.
if (1) {
echo -a hello $iif(cheesecake > pie,$v1,$v2)
echo -a hello $v1
}
;$v1 and $v2 also work with while loops
var %i = 1
while (%i < 2) {
echo -a $v1
inc %i
}
;Re-emphasizing two more things:
;First that they keep their values outside of the comparison itself.
;Second that they are still assigned, even when conditional fails.
;$v1 uses the failed attempt in the while loop when %i increments to 2
echo -a and that concludes the test of v1 and v $+ $v1
}