#include "$/inc/console.inc"
function iif(bool testVal, sys ifTrue, ifFalse) as sys
if testVal then return ifTrue
return ifFalse
end function
function iif(bool testVal, float ifTrue, ifFalse) as float
if testVal then return ifTrue
return ifFalse
end function
function iif(bool testVal, double ifTrue, ifFalse) as double
if testVal then return ifTrue
return ifFalse
end function
function iif(bool testVal, string ifTrue, ifFalse) as string
if testVal then return ifTrue
return ifFalse
end function
'Test
print "" iif((14==13), (14 * 15), "False") & cr '( == )
'-----------------------
int A=5, B=6, C
c = iif(A > B, 100, 200)
print c & cr
'-----------------------
int a=1, b=2
string c
printl "a = 1 b = 2"
c = iif((a==b), "TRUE", "FALSE") '( == )
printl "iif((a==b), TRUE, FALSE) returned " c
c = iif(a <> b, "TRUE", "FALSE")
printl "iif(a <> b, TRUE, FALSE) returned " c
c = iif(a < b, "TRUE", "FALSE")
printl "iif(a < b, TRUE, FALSE) returned " c
c = iif(a > b, "TRUE", "FALSE")
printl "iif(a > b, TRUE, FALSE) returned " c
'-----------------------
string buf1, buf2, str1
buf1 = "ABCDEFGHI"
buf2 = "ABCDEFGHI"
printl cr "buf1 = ABCDEFGHI buf2 = ABCDEFGHI"
str1 = iif((buf1==buf2), "TRUE", "FALSE") '( == )
if str1 = "TRUE" then
printl "buf1 is equal buf2"
elseif str1 = "FALSE" then
printl "buf1 is not equal buf2"
end if
'-----------------------
double hour = 12.30
string greeting = "Good" + iif((hour > 17), " evening.", " day.") '( > )
printl cr greeting
'-----------------------
printl "Enter ... " : waitkey
macro iifType(typ)
function iif(bool testVal, typ ifTrue, ifFalse) as typ
if testVal then return ifTrue
return ifFalse
end function
end macro
iifType sys
iifType float
iifType double
iifType string
'test
r="A"
s="B"
t="B"
r = iif ( (s==t), "true","false" ) 'Okay
print r
r = iif ( (s=t), "true","false" ) 'Okay
print r
r = iif ( (s==t), "true","false" ) '???
print r