06-03-2023, 10:32 PM
I get by like this:
It requires three functions, one for integers, another for floating point and another for strings, that's the main drawback. But be glad BASIC doesn't have a "boolean" type that would have prevented the straight-out use of a condition which is evaluated and passed along as integer value.
Code: (Select All)
dim i as _integer64, f as _float, x as _integer64, y as _float, s as string
i = iff(x > 5, x - 1, x * 2)
f = ifff(y < 0, 1, sqr(y))
s = iffs$(x = 0, "true", "false")
end
function iff&& (cond%%, truevalu&&, falsvalu&&)
if cond%% then
iff&& = truevalu&&
exit function
end if
iff&& = falsvalu&&
end function
function ifff## (cond%%, truevalu##, falsvalu##)
if cond%% then
ifff## = truevalu##
exit function
end if
ifff## = falsvalu##
end function
function iffs$ (cond%%, truevalu as string, falsvalu as string)
if cond%% then
iffs$ = truevalu
exit function
end if
iffs$ = falsvalu
end function
It requires three functions, one for integers, another for floating point and another for strings, that's the main drawback. But be glad BASIC doesn't have a "boolean" type that would have prevented the straight-out use of a condition which is evaluated and passed along as integer value.