True and False (Advanced) |
Top Previous Next |
When a comparison is made, it produces a true or false value, like 2 + 3 produces the value 5. The reserved word "false" is just another way to represent the integer 0, and likewise "true" is equal to -1 (=$FFFF).
Using these concepts and adding the new variable High, the previous example from the GUESS program can be rewritten as:
High:= Guess > Number; if High = true then Text(0, "Too high") else Text(0, "Too low")
Going one step further, since High is assigned either true or false and since:
true = true is true
and:
false = true is false,
the "if" statement can be simplified as:
if High then Text(0, "Too high") else Text(0, "Too low")
|