The IF
function allows you to evaluate whether a certain expression is TRUE
(not 0) or FALSE
.
(0). Depending on that check, the function will return the second (if TRUE
) or third (if FALSE
)
argument.
This function evaluates the expression at compile time: it follows that the return
value does not change at runtime. There are three versions of this function, one for each
type of value that can be returned. There is a version that returns integers, one for
floating point numbers, and one for strings.
This function is particularly useful for carrying out a conditional evaluation of constants which,
otherwise, would require evaluation at runtime, wasting time and occupying useless space.
= IF (exp, valueTrue, valueFalse )
pictureToUse = IF(SCREEN WIDTH > 160, "large.png", "small.png" )
Join BASIC 10Liner Contest with ugBASIC!
An interesting competition is held at the beginning of each year: the
BASIC 10Liner Contest.
It is possible to use ugBASIC to participate in the next
"BASIC10Liner" competition, in the following categories:
IF (function) ↔ If
If you have found a problem with this keyword, if you think there is a bug or, more
simply, you would like it to be improved, open an issue for this example on GitHub.
Thank you!
open an issue
BACK TO KEYWORDS