PRGM CTL (Control) Instructions

This section describes the PRGM CTL (Control) Instructions.

Topic Links

PRGM CTL Menu

To display the PRGM CTL (program control) menu, press ¼ from the program editor only.

Important Tip: To quickly find a command, use ƒ } or ƒ to page through screens.

 

 

 

CTRL

I/O

COLOR

EXEC

HUB

 

 

 

 

 

 

 

 

 

 

 

 

Description

1:

If

Creates a conditional test.

2:

Then

Executes commands when If is true.

3:

Else

Executes commands when If is false.

4:

For(

Creates an incrementing loop.

5:

While

Creates a conditional loop.

6:

Repeat

Creates a conditional loop.

7:

End

Signifies the end of a block.

8:

Pause

Pauses program execution.

9:

Lbl

Defines a label.

0:

Goto

Goes to a label.

A:

Wait

Suspends execution of a program for a given time.

B:

IS>(

Increments and skips if greater than.

C:

DS<(

Decrements and skips if less than.

D:

Menu(

Defines menu items and branches.

E:

prgm

Executes a program as a subroutine.

F:

Return

Returns from a subroutine.

G:

Stop

Stops execution.

H:

DelVar

Deletes a variable from within program.

I:

GraphStyle(

Designates the graph style to be drawn.

J:

GraphColor(

Designates the color of the graph to be drawn

K:

OpenLib(

Extends TI-Basic (not available)

L:

ExecLib(

Extends TI-Basic (not available)

Note: Press à when a command is highlighted in a menu to use the syntax help for your programming.

These menu items direct the flow of an executing program. They make it easy to repeat or skip a group of commands during program execution. When you select an item from the menu, the name is pasted to the cursor location on a command line in the program.

To return to the program editor without selecting an item, press .

Controlling Program Flow

Program control instructions tell the TI CE graphing calculator which command to execute next in a program. If, While, and Repeat check a defined condition to determine which command to execute next. Conditions frequently use relational or Boolean tests, as in:

If A<7:A+1!A
or
If N=1 and M=1:Goto Z

 


If

Use If for testing and branching. If condition is false (zero), then the command immediately following If is skipped. If condition is true (nonzero), then the next command is executed. If instructions can be nested.

:If condition
:command (if true)
:command

Program

Output

 


If-Then

Then following an If executes a group of commands if condition is true (nonzero). End identifies the end of the group of commands.

:If condition
:Then
:
command (if true)
:command (if true)
:End
:
command

Program

Output

 


If-Then-Else

Else following If-Then executes a group of commands if condition is false (zero). End identifies the end of the group of commands.

:If condition
:Then
:
command (if true)
:command (if true)
:Else
:
command (if false)
:command (if false)
:End
:
command

Program

Output

Note: Press Í to repeat the program.

 


For(

For( loops and increments. It increments variable from begin to end by increment. increment is optional (default is 1) and can be negative (end<begin). end is a maximum or minimum value not to be exceeded. End identifies the end of the loop. For( loops can be nested.

:For(variable,begin,end[,increment])
:
command (while end not exceeded)
:command (while end not exceeded)
:End
:
command

Program

Output

 


While

While performs a group of commands while condition is true. condition is frequently a relational test. condition is tested when While is encountered. If condition is true (nonzero), the program executes a group of commands. End signifies the end of the group. When condition is false (zero), the program executes each command following End. While instructions can be nested.

:While condition
:command (while condition is true)
:command (while condition is true)
:End
:
command

Program

Output

 


Repeat

Repeat repeats a group of commands until condition is true (nonzero). It is similar to While, but condition is tested when End is encountered; therefore, the group of commands is always executed at least once. Repeat instructions can be nested.

:Repeat condition
:command (until condition is true)
:command (until condition is true)
:End
:
command

Program

Output

 


End

End identifies the end of a group of commands. You must include an End instruction at the end of each For(, While, or Repeat loop. Also, you must paste an End instruction at the end of each If‑Then group and each If‑Then‑Else group.

 


Pause

Pause suspends execution of the program so that you can see answers or graphs. During the pause, the pause indicator is on in the top-right corner.

Pause without an argument temporarily pauses the program. If the DispGraph or Disp instruction has been executed, the appropriate screen is displayed. Press Í to resume execution.
Pause with value displays value on the current home screen. value can be scrolled. Pause value. Press Í to resume execution.
Pause with value and time displays value on the current home screen and execution of the program continues for the time period specified. For time only, use Pause “”,time where the value is a blank string. Time is in seconds. Pause value,time.

Note: When using TI Connect CE Program Editor, Pause must have a space after the command even if no argument is entered.

Program

Output

 


Lbl, Goto

-------------------------------

Lbl

Lbl (label) and Goto (go to) are used together for branching.

Lbl specifies the label for a command. label can be one or two characters (A through Z, 0 through 99, or q).

Lbl label

-------------------------------

Goto

Goto causes the program to branch to label when Goto is encountered.

Goto label

 

Program

Output

 


Wait

Wait suspends execution of a program for a given time. Maximum time is 100 seconds. During the wait time, the busy indicator is on in the top-right corner of the screen.

Wait time

Program

Output: “Bye!” displays after 5 seconds.

 


IS>(

IS>( (increment and skip) adds 1 to variable. If the answer is > value (which can be an expression), the next command is skipped; if the answer is { value, the next command is executed. variable cannot be a system variable.

:IS>(variable,value)
:
command (if answer  value)
:command (if answer > value)

Program

Output

Note: IS>( is not a looping instruction.

 


DS<(

DS<( (decrement and skip) subtracts 1 from variable. If the answer is < value (which can be an expression), the next command is skipped; if the answer is | value, the next command is executed. variable cannot be a system variable.

:DS<(variable,value)
:
command (if answer ‚ value)
:command (if answer < value)

Program

Output

Note: DS<( is not a looping instruction.

 


Menu(

Menu( sets up branching within a program. If Menu( is encountered during program execution, the menu screen is displayed with the specified menu items, the pause indicator is on, and execution pauses until you select a menu item.

The menu title is enclosed in quotation marks ( " ). Up to nine pairs of menu items are allowed. Each pair comprises a text item (also enclosed in quotation marks) to be displayed as a menu selection, and a label item to which to branch if you select the corresponding menu selection.

Menu("title","text1",label1,"text2",label2, . . .)

Program

Output

The program above pauses until you select 1 or 2. If you select 2, for example, the menu disappears and the program continues execution at Lbl B.

 


prgm

Use prgm to execute other programs as subroutines. When you select prgm, it is pasted to the cursor location. Enter characters to spell a program name. Using prgm is equivalent to selecting existing programs from the PRGM EXEC menu; however, it allows you to enter the name of a program that you have not yet created.

prgmname

Note: You cannot directly enter the subroutine name when using RCL. You must paste the name from the PRGM EXEC menu.

 


Return

Return quits the subroutine and returns execution to the calling program, even if encountered within nested loops. Any loops are ended. An implied Return exists at the end of any program that is called as a subroutine. Within the main program, Return stops execution and returns to the home screen.

 


Stop

Stop stops execution of a program and returns to the home screen. Stop is optional at the end of a program.

 


DelVar

DelVar deletes from memory the contents of variable.

DelVar variable

 


GraphStyle(

GraphStyle( designates the style of the graph to be drawn. function# is the number of the Y= function name in the current graphing mode. graphstyle is a number from 1 to 7 that corresponds to the graph style, as shown below.

1 = ç (Thin)
2 = è (Thick)
3 = é (Shade above)
4 = ê (Shade below)

5 = ë (Path)
6 = ì (Animate)
7 = í (Dot‑Thick)
8 =í (Dot‑Thin)

GraphStyle(function#,graphstyle)

For example, GraphStyle(1,5) in Func mode sets the graph style for Y1 to ë (path; 5).

Not all graph styles are available in all graphing modes.

 


GraphColor

GraphColor( designates the color of the graph to be drawn. function# is the number of the Y= function name in the current graphing mode. color# is a number from 10 to 24 that corresponds to the graph color, as shown in the table below:

Color Number

Color Name

10

BLUE

11

RED

12

BLACK

13

MAGENTA

14

GREEN

15

ORANGE

16

BROWN

17

NAVY

18

LTBLUE

19

YELLOW

20

WHITE

21

LTGRAY

22

MEDGRAY

23

GRAY

24

DARKGRAY

You can also choose a color name in the ½ menu (color sub-menu).

GraphColor(function#,color#)

For example,GraphColor(2, 4) or GraphColor(2, MAGENTA).

 


OpenLib(

Extends TI-Basic (not available)

 


ExecLib(

Extends TI-Basic (not available)