Last modified on 8 May 2012, at 00:15

TI-Basic 84 Programming/Conditional Functions

IfEdit

If, PRGM:CTL:1, is a command that, when it's condition is true, will execute the next line of code. If the condition happens to be false, then the program will skip to the second line of code after the statement.

Syntax: IfEdit

:If condition
  • Where condition either an (in)equality (X=3, A>B), or an expression (5+2X), which resolves to be either true (non-zero) or false (zero).


Ex: IfEdit

PROGRAM:TEMP
:5→X
:If X>3
:Disp "X IS MORE THAN 3"
:Disp "END OF PROGRAM"
prgmTEMP
X IS MORE THAN 3
END OF PROGRAM

ElseEdit

Else, PRGM:CTL:3, is a command that, when a previous If statement is not met, will execute the next line of code. If the condition happens to be false, then the program will skip to the second line of code after the statement.

Syntax: ElseEdit

:If condition
://some action
:Else
://some other action
  • Else executes when the condition in the If statement is not met.

Ex: ElseEdit

PROGRAM:TEMP
:5→X
:If X>3
:Disp "X IS MORE THAN 3"
:Else
:Disp "X IS LESS THAN OR EQUAL TO 3"
:Disp "END OF PROGRAM"
prgmTEMP
X IS MORE THAN 3 or X IS LESS THAN OR EQUAL TO 3
END OF PROGRAM

ThenEdit

Then, PRGM:CTL:2, is a command used to have a conditional statement (If or Then) execute a block of code as opposed to a single statement.

Syntax: ThenEdit

:If condition
:Then
://some code
://some more code
:End
  • Code block is started with a Then statement and ended with the End, PRGM:CTL:7,


Previous: Input
Next: Test Conditions and Logical Operators
Table of Contents: TI-Basic 84 Programming