Jump to content

TI-Basic 84 Programming/Control Flow Statements

From Wikibooks, open books for an open world

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: If

[edit | edit source]
: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: If

[edit | edit source]
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


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: Else

[edit | edit source]
:If condition
:Then
://some action
:Else
://some other action
  • Else executes when the condition in the If statement is not met.

Ex: Else

[edit | edit source]
PROGRAM:TEMP
5→X
If X>3
Then
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
END OF PROGRAM


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: Then

[edit | edit source]
: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