Skip to content
This repository was archived by the owner on Jan 26, 2022. It is now read-only.

If and Else

Peter Tillema edited this page Nov 26, 2018 · 2 revisions

If statements checks the condition code given to them, if the condition evaluates to false (0), the code inside the If statement does not execute, otherwise, the code executes. If the statement has an Else token before the End token, the code inside the Else statement will be executed. The difference here in ICE is that ICE does not have a Then token. To make a comparison to TI-BASIC, this means that all If's in ICE 'automatically' have a Then after them, meaning that all If statements in ICE must be paired with an End token. Example:

rand→A
ClrHome
If A>6400
    Disp "A IS GREATER THAN 6400"
Else
    Disp "A IS <= 6400"
End

The example generates a random number and stores it into A, then checks if A is greater than 6400. If A is greater than 6400, the code inside the If-Else block will be executed, meaning a string is displayed to the screen. If A is not greater than 6400 (if it's equal to or less than 6400), the code inside the Else-End block will be executed, displaying "A IS <= 6400" to the screen.

Clone this wiki locally