TI Extended Basic - Linked
TI Extended Basic - Linked
1
Click here to
Return to Table of Contents
This book was developed and written by:
Robert E. Whitsitt II
ISBN #0-89512-045-3
Library of Congress Catalog #80-54899
This book has been scanned and converted to electronic form by:
Manolis Kiagias
For corrections, additions and suggestions, contact me:
[email protected]
2
Click here to
Return to Table of Contents
TABLE OF CONTENTS
Chapter 1 – Introduction 7
Features 8
Changes from TI Basic 10
How to Use this Manual 10
How to Use the Computer 11
Operating in TI Extended Basic 11
Special Key Functions 12
Chapter 2 – Overview of TI Extended Basic 15
Commands 16
Assignments and Input 17
Output 18
Functions, Subroutines, and Subprograms 19
Built in Functions 20
User-Defined Functions 21
Subroutines 21
Built in Subprograms 21
User-Written Subprograms 23
Sound, Speech and Color 24
Sprites 25
Debugging 26
Error Handling 26
Program Entry Example 27
Chapter 3 – TI Extended Basic Conventions 37
Running a Program on Power up 38
Files 38
Line Numbers 38
Lines 38
Special Symbols 39
Spaces 39
Numeric Constants 39
String Constants 39
Variables 39
Numeric Expressions 41
String Expressions 41
Relational Expressions 41
Logical Expressions 42
3
Click here to
Return to Table of Contents
Chapter 4 – Reference Section 45
ABS 46
ACCEPT 47
ASC 50
ATN 51
BREAK 52
BYE 54
CALL 55
CHAR 56
CHARPAT 59
CHARSET 60
CHR$ 60
CLEAR 61
CLOSE 62
COINC 64
COLOR 66
CONTINUE 68
COS 69
DATA 70
DEF 72
DELETE 74
DELSPRITE 75
DIM 76
DISPLAY 77
DISPLAY…USING 79
DISTANCE 80
END 81
EOF 82
ERR 83
EXP 85
FOR-TO-STEP 86
GCHAR 88
GOSUB 89
GOTO 91
HCHAR 92
IF-THEN-ELSE 94
IMAGE 97
INIT 101
INPUT 102
INPUT (with Files) 104
INT 107
JOYST 108
KEY 109
LEN 110
4
Click here to
Return to Table of Contents
LET 111
LINK 112
LINPUT 113
LIST 114
LOAD 115
LOCATE 116
LOG 117
MAGNIFY 118
MAX 121
MERGE 122
MIN 124
MOTION 125
NEW 126
NEXT 127
NUMBER 128
OLD 129
ON BREAK 130
ON ERROR 131
ON GOSUB 133
ON GOTO 135
ON WARNING 137
OPEN 138
OPTION BASE 141
PATTERN 142
PEEK 143
PI 144
POS 145
POSITION 146
PRINT 147
PRINT USING 150
RANDOMIZE 151
READ 152
REC 153
REM 154
RESEQUENCE 155
RESTORE 156
RETURN (with ON GOSUB) 157
RETURN (with ON ERROR) 158
RND 159
RPT$ 160
RUN 161
SAVE 163
SAY 164
SCREEN 165
5
Click here to
Return to Table of Contents
SEG$ 166
SQN 167
SIN 168
SIZE 169
SOUND 170
SPGET 172
SPRITE 173
SQR 178
STOP 178
STR$ 179
SUB 180
SUBEND 184
SUBEXIT 184
TAB 185
TAN 186
TRACE 186
UNBREAK 187
UNTRACE 187
VAL 188
VCHAR 188
VERSION 190
APPENDICES
Appendix A – List of Illustrative Programs 192
Appendix B – List of Commands, Statements and Functions 194
Appendix C – ASCII Codes 196
Appendix D – Musical Tone Frequencies 197
Appendix E – Character Sets 198
Appendix F – Pattern-Identifier Conversion Table 198
Appendix G – Color Codes 199
Appendix H – Color Combinations 200
Appendix I – Split Console Keyboard 201
Appendix J – Character Codes for Split Keyboard 201
Appendix K – Mathematical Functions 202
Appendix L – List of Speech Words 203
Appendix M – Adding Suffixes to Speech Words 206
Appendix N – Error Messages 212
6
Click here to
Return to Table of Contents
INTRODUCTION
(Remainder of this page intentionally left blank)
7
Click here to
Return to Table of Contents
INTRODUCTION
FEATURES
Texas Instruments Extended BASIC is a powerful computer programming language for use
with the Texas Instruments TI-99/4 Home Computer. It has the features expected from a
high level language plus additional features not available in many other languages, including
those designed for use with large, expensive computers.
TI Extended BASIC goes beyond Texas Instruments BASIC to enhance the capability and
flexibility of your computer system by adding these features:
Input and Output - The ACCEPT statement allows the input of data from anywhere on the
screen. You may clear the screen, accept only certain characters, and limit the number of
characters entered using this statement. The DISPLA Y statement has been enhanced to
allow putting data anywhere on the screen, and DISPLAY ... USING, PRINT ... USING, and
IMAGE have been added for ease in formatting data on the display screen and peripheral
devices.
Subprograms - Subprograms with local variables (affecting only values within the
subprogram) can be written in TI Extended BASIC. Commonly used subprograms may be
stored on a diskette and added to programs as needed. Statements included are SUB,
SUBEND, and SUBEXIT. The MERGE command has been added and the SAVE command
modified to allow the merging of programs from diskettes.
Sprites - Sprites are specially defined graphics with the ability to move smoothly on the
screen. To provide the sprite capability, the following subprograms have been included in TI
Extended BASIC: COINC, DELSPRITE, DISTANCE, LOCATE, MAGNIFY, MOTION, PATTERN,
POSITION, and SPRITE. COLOR and CHAR have been redesigned so they also can affect
sprites
Functions - MAX, returning the larger of two numbers; MIN, returning the smaller of two
numbers; and PI, returning the value of p, have been included in TI Extended BASIC.
Error Handling - With TI Extended BASIC, you can choose what action is taken if there is a
minor error (which in TI BASIC causes a warning message), a major error (which in TI BASIC
causes an error message and stops the program), or a breakpoint (which in TI BASIC causes
the program to halt). The new statements allowing this control are ON WARNING, ON
ERROR, and ON BREAK. RETURN has been modified for use with error handling. The CALL
ERR statement can be used to determine the nature of an error that occurs in a program.
8
Click here to
Return to Table of Contents
RUN as a Statement - RUN can be used as a statement as well as a command. RUN has
also been modified to allow you to specify which program to run. As a result, one program
can load and run another program from a diskette. You can, therefore, write programs of
almost unlimited size by breaking them into pieces and letting each segment run the next.
Power-up Program Execution - When TI Extended BASIC is first chosen, it searches for a
program named LOAD on the diskette in disk drive 1. If that program exists, it is placed in
memory and run.
Multiple Statement Lines - TI Extended BASIC allows more than one statement to be on a
line. This feature speeds program execution, saves memory, and allows logical units (for
example FOR-NEXT loops) to be on a single line.
SAVE and LIST Protection - You may protect your programs from being saved or listed,
preventing unauthorized copies of and changes in your programs. This, in conjunction with
the copy protection feature of the Disk Manager Module, can completely secure a TI Extended
BASIC program.
IF-THEN- ELSE - The IF-THEN-ELSE statement now allows statements as the consequences
of the comparison. This expansion permits statements such as "IF X<4 THEN GOSUB 240
ELSE X=X+ 1".
Multiple Assignments - TI Extended BASIC allows you to assign a value to more than one
variable in a LET statement, saving statements and permitting more efficient programming.
Comments - In addition to the REM statement, comments can be added to the ends of lines
in TI Extended BASIC, allowing detailed internal documentation of programs.
Assembly Language Support - With the optional Memory Expansion unit (available
separately), TMS9900 assembly language subprograms may be loaded and run. The
subprograms INIT, LOAD, LINK, and PEEK are used to access assembly language
subprograms. There are no facilities for writing assembly language programs on the TI-99/4
Home Computer.
Information - The SIZE command has been added to tell you how much memory remains
unused in your computer. The VERSION subprogram returns a value which indicates the
version of BASIC that is in use. The CHARPAT subprogram returns a character string
indicating the pattern which defines a character.
Memory Expansion - TI Extended BASIC allows the use of an optional Memory Expansion
peripheral which permits much larger programs to be written.
9
Click here to
Return to Table of Contents
CHANGES FROM TI BASIC
The enhancements described above have made some slight changes necessary in other areas
of TI BASIC. Because of these, some programs written in TI-99/4 BASIC may not run in TI
Extended BASIC.
• The maximum program size is now 864 bytes smaller than in TI BASIC. If you have
the Memory Expansion peripheral, much larger programs may be written.
• The characters in character sets 15 and 16 are no longer available. That memory
area is used by TI Extended BASIC to keep track of sprites.
• Most programs written in TI BASIC will also run in TI Extended BASIC without
difficulty. Under certain circumstances, however, such as using a TI Extended
BASIC keyword as a variable in a TI BASIC program, programs written in TI BASIC
may not run in TI Extended BASIC. However, you can always load TI BASIC
programs into TI Extended BASIC. Programs using the enhancements of TI
Extended BASIC will not run correctly in TI BASIC.
This manual assumes that you are already experienced in programming with TI BASIC.
Statements, commands, and functions that are the same as in TI BASIC are only discussed
briefly here. For a complete discussion, see the User's Reference Guide that came with your
TI-99/4 Home Computer.
The additional features of TI Extended BASIC are explained in detail and illustrated with
examples and programs. To get the maximum use from TI Extended BASIC, read this manual
carefully, entering and running the sample programs to see how they work. Even features
that are unchanged from TI BASIC should be reviewed. You may find that you have been
neglecting a useful statement or discover a new way to use statements in different
combinations.
The remainder of this chapter reviews the basics of operating with TI Extended BASIC. The
second chapter discusses the features of TI Extended BASIC and includes a detailed example
of entering a program. The third chapter discusses the conventions of operation with TI
Extended BASIC. The fourth chapter is a reference section which discusses, in alphabetical
order, all TI Extended BASIC commands, statements, and functions.
The 14 appendices contain much useful information, including ASCII character codes, error
codes, color codes, keyboard codes, and instructions on how to add suffixes to speech words.
10
Click here to
Return to Table of Contents
HOW TO USE THE COMPUTER
Before using the computer with TI Extended BASIC, you must insert the Solid State Software
TM Command Module into the computer. If the computer is off, slowly slide the module into
the slot on the console until it is in place.
Then turn the computer on. (If you have peripherals, turn them on before turning on the
computer.) The master title screen appears. If the computer is already on, return to the
master title screen. Then slide the module into the slot.
Press any key to make the master selection list appear. The title of the module, TI EXTENDED
BASIC, is third on the list. Type 3 to select TI Extended BASIC.
There are three main operating modes in TI Extended BASIC: Command Mode, Edit Mode,
and Run Mode.
Command Mode is the mode entered when you choose TI Extended BASIC on the master
selection list. In the Command Mode you may enter TI Extended BASIC commands,
statements that may be used as commands, and program lines.
Edit Mode is used to edit existing lines of a TI Extended BASIC program. To enter Edit Mode,
type a line number and press either SHIFT E (UP) or SHIFT X (DOWN). (TI BASIC also allows
EDIT followed by a line number, which TI Extended BASIC does not allow.) The line specified
is then displayed on the screen. You may change it by typing a new line, by typing over part
of the old line, or by using the editing keys discussed below. You are also in the Edit Mode
when you press SHIFT R (REDO) to repeat a program line or command.
In Run Mode, a TI Extended BASIC program is executed. You can stop a running program
only by pressing SHIFT C (CLEAR), which causes a breakpoint, or with SHIFT Q (QUIT).
Note: SHIFT Q (QUIT) also erases the entire program, returns you to the master title screen,
and may delete information from some of your files. The use of BYE is recommended in place
of SHIFT Q (QUIT) to leave TI Extended BASIC.
11
Click here to
Return to Table of Contents
SPECIAL KEY FUNCTIONS
The following are the keys that have a special function when pressed at the same time as the
SHIFT key: E, D, S, X, R, T, G, F, C, Q. Each of these keys is discussed below.
SHIFT E (UP) is used in the Edit Mode. If you are not in the Edit Mode, you may enter it by
typing a line number and then pressing SHIFT E (UP). The line specified is then displayed on
the screen and may be edited. If you are already in the Edit Mode, pressing SHIFT E (UP)
enters the present line as you have changed it and displays the next lower numbered line in
the program. Pressing SHIFT E (UP) when you are at the lowest numbered line in the
program returns you to the Command Mode. If you are entering a line in the Command
Mode, SHIFT E (UP) has the same effect as ENTER.
SHIFT D (RIGHT) moves the cursor one space to the right. The cursor does not erase or
change the characters as it passes over them. At the end of a line on the screen, the cursor
wraps around to the next screen line. When the cursor is at the end of an input line, it does
not move.
SHIFT S (LEFT) moves the cursor one space to the left. The cursor does not erase or change
characters as it passes over them. If the cursor is at the beginning of a line, the cursor does
not move. If the cursor is at the left margin but not at the beginning of an input line, the
cursor goes to the right margin of the screen line above it.
12
Click here to
Return to Table of Contents
SHIFT X (DOWN) is used in the Edit Mode. If you are not in the Edit Mode, you may enter it
by typing a line number and then pressing SHIFT X (DOWN). The line specified by the line
number is then displayed on the screen and may be edited. If you are in the Edit Mode,
pressing SHIFT X (DOWN) enters the present line as you have changed it and displays the
next higher numbered line in the program. Pressing SHIFT X (DOWN) when you are at the
highest numbered line in the program returns you to the Command Mode. If you are entering
a line in the Command Mode, SHIFT X (DOWN) has the same effect as ENTER.
SHIFT R (REDO) causes the characters on the line previously input to reappear on the
screen. Thus if you wish to enter a line similar to the most recently entered line, press SHIFT
R (REDO). If you enter a line and make a mistake, you can recall the line using SHIFT R
(REDO) and correct it using the Edit Mode features. This key lets you avoid retyping a long
line.
SHIFT T (ERASE) erases all characters on the current line, but leaves the cursor on that line.
If you are in the Command Mode, the cursor returns to the left margin of the screen and you
may enter a new line, including the line number. However, if you are editing a line or the
computer is providing the line numbers (through the use of NUM), the line number is not
erased.
SHIFT G (INSERT) instructs the computer to accept inserted characters. Each subsequent
key that you type is inserted at the cursor position and the character at the cursor position
and all characters to the right of the cursor are shifted one position to the right. Insertion
continues with each character typed until ENTER or one of the other special function keys is
pressed. Characters at the end of a long input line may be lost.
SHIFT F (DELETE) deletes the character that the cursor is on and shifts all characters to the
right of the cursor one position to the left.
SHIFT C (CLEAR) performs different functions depending on the mode that you are in. If you
are in the Edit Mode, any changes that were made to the line are ignored, including SHIFT T
(ERASE), and the computer returns to Command Mode. If you are in Run Mode, the program
is stopped with a breakpoint. If you are in Command Mode, the characters that you have
typed on the current line are deleted. When using SHIFT C (CLEAR) to stop a program, hold
the keys down until TI Extended BASIC recognizes the breakpoint.
13
Click here to
Return to Table of Contents
SHIFT Q (QUIT) returns the computer to the master title screen. When you press SHIFT Q
(QUIT), all data and program material are erased from the computer's memory. If you are
using a disk system, some of your data files may be lost. Leave TI Extended BASIC by
entering BYE instead of using SHIFT Q (QUIT).
ENTER indicates that you have finished typing the information on the current line and are
ready for the computer to process it.
14
Click here to
Return to Table of Contents
OVERVIEW OF TI EXTENDED BASIC
This chapter briefly describes the TI Extended BASIC commands, statements, and functions
and suggests ways in which you can use them.
The first eight sections are Commands; Assignments and Input; Output; Functions;
Subroutines, and Subprograms; Sound, Speech, and Color; Sprites; Debugging; and Error
Handling. The final section is an example of the entry of a program, showing the entry
process and the use of some of the TI Extended BASIC elements.
15
Click here to
Return to Table of Contents
COMMANDS
Commands tell the computer to perform a task immediately (that is, as soon as you press
ENTER), while statements are executed when a program is run. In TI Extended BASIC many
commands can be used as statements, and most statements can be used as commands. A list
of all the commands, statements, and functions is given in Appendix B, indicating the
commands that can be used as statements and the statements that can be used as
commands.
NEW
To remove a program from TI Extended BASIC to prepare the computer to accept a new
program, use the NEW command. Programs are also removed from memory by the OLD
command and the RUN command when used with a file name.
When you are entering a program, the computer assigns line numbers for you if you enter
the NUMBER command. If you wish to resequence the line numbers of a program after it is
written, use the RESEQUENCE command.
LIST
To review the program that you have entered, use the LIST command. The program can be
listed on the screen or to a peripheral device.
RUN
The RUN command instructs the computer to perform, or "execute," a program. The RUN
command may be followed by a line number to have it start program execution at a specific
line, or by a device and filename to load and execute a program from a diskette.
All of these commands are related to "debugging" a program, which is finding a problem that
causes an error condition or an incorrect result. These commands are discussed further in the
"Debugging and Error Handling" section of this chapter.
When you are finished working on a program, you may want to store it on a cassette or
diskette for later use. The SAVE command, followed by the name of the storage device and a
program name, performs this task for you. Then, when you wish to reuse, list, edit, or change
a program, you can load it into memory with the OLD command. If a program has been
saved using the merge option, you can combine it with a program already in memory with the
MERGE command. When you have no further use for a program that has been saved on
diskette, you can remove it with the DELETE command.
16
Click here to
Return to Table of Contents
SIZE
The SIZE command lets you determine how much memory space is left, so you can decide
whether to continue to add program lines or end the program and have a second program
run from the first program with RUN used as a statement.
BYE
When you have finished using TI Extended BASIC, use the BYE command to return to the
master title screen.
Several of the commands (RUN, BREAK, UNBREAK, TRACE, UNTRACE, and DELETE) can also
be used as statements in programs.
This section discusses statements in TI Extended BASIC that assign values to variables and
enter data into programs.
If you know what values are to be assigned to variables, use LET or READ statements. LET is
used when you are assigning a fairly small number of values or are calculating values to be
assigned, and READ is used, in conjunction with DATA and RESTORE, when you are assigning
numerous values.
When you want the user of the program to assign values, it is customary to give a prompt
that asks for the necessary information. INPUT allows you to give a prompt and accept input.
INPUT only allows the entry of values at the bottom of the screen and cannot check to see
that the data entered is the type of information the program expects. The final limitation on
INPUT is that commas and quotation marks affect what is entered. With LINPUT, there is no
editing of what is input, so commas and quotation marks can be input. Both INPUT and
LINPUT may be used to input data from files on cassettes and diskettes.
ACCEPT
ACCEPT allows input from most screen positions. Using ACCEPT eliminates the necessity of
entering data at the bottom of the screen and the "scrolling" of the INPUT statement.
However, ACCEPT doesn't allow a prompt as the INPUT statement does. Therefore, a PRINT
or DISPLAY statement must be included in the program to tell the user the type of entry that
is required. ACCEPT can check the input to see that it is numeric, alphabetical, or specific
characters. ACCEPT is for screen and keyboard use only.
17
Click here to
Return to Table of Contents
CALL KEY and CALL JOYST
If pressing a single key is all that the program user is required to do, then CALL KEY can be
used. For example, if a Y for "yes" or N for "no" is the required response, use the CALL KEY
statement to accept the entry. CALL KEY does not display a character on the screen. It scans
the keyboard or a portion of the keyboard to see if a key has been pressed. The major
limitation of CALL KEY is that only a single keystroke is accepted. The data is not recorded as
a character, but rather as the ASCII code for the character or as some other code. (See
Appendices C and J for a list of the codes used.) If you wish to show the key that was
pressed, you must use DISPLAY, PRINT, CALL VCHAR, or CALL HCHAR. The input from a
Wired Remote Controller can be used with CALL JOYST. As with CALL KEY, the data is not
displayed, and no scrolling takes place.
CALL CHARPAT, CALL COINC, CALL DISTANCE, CALL ERR, FOR-TO-STEP, CALL
GCHAR, CALL POSITION, NEXT, CALL SPGET, and CALL VERSION
Each of these statements assigns one or more values to a variable. CALL CHARPAT assigns a
value that specifies the pattern of a character. CALL COINC assigns a value to tell if sprites or
a sprite and a point on the screen are at or near the same location on the screen. CALL
DISTANCE indicates the distance between two sprites or a sprite and a point on the screen.
CALL ERR specifies the error that occurred and where it occurred. CALL GCHAR reads what
character is at a given screen location. CALL POSITION reads where a sprite is on the screen.
CALL SPGET assigns the coded value of a speech phrase to a variable to be used with CALL
SAY. CALL VERSION indicates the version of BASIC in use.
FOR- TO-STEP and NEXT deserve special comment. The FOR-TO-STEP statement sets the
value of a variable so that it can be used to control the number of times a loop is executed.
Each time NEXT is encountered, the value of the variable is changed. After the loop has been
completed, the variable has a value that is the first value outside the range specified in the
FOR- TO-STEP statement.
OUTPUT
This section discusses the TI Extended BASIC statements which are used to output data
during program execution. Usually, output consists of displaying information on the screen,
printing data on a printer, or saving data on an external device. However, output can also
involve changing the color of the screen, changing the colors of characters, making noises,
speaking, or sending data to peripheral devices.
18
Click here to
Return to Table of Contents
PRINT, DISPLAY, PRINT...USING, DISPLAY...USING, and IMAGE
The two most frequently used output statements are PRINT and DISPLAY.
The print separators (comma, semicolon, and colon) and the TAB function are used to control
the placement of information as it is output. PRINT displays items at the bottom of the screen
and scrolls them upward, one line at a time. With DISPLAY, you can display data almost
anywhere on the screen without scrolling. DISPLAY can also clear the screen, erase
characters on a line and cause a beep.
PRINT...USING and DISPLAY...USING are like PRINT and DISPLAY except that the format of
the printed or displayed characters is determined by the USING clause, possibly in
conjunction with an IMAGE statement. The USING clause allows exact control of the format.
PRINT and PRINT ...USING, possibly in conjunction with IMAGE, are the only output
statements that can be used to send data to an external device.
CALL HCHAR and CALL VCHAR place a character at any screen position and optionally repeat
it horizontally or vertically. CALL SPRITE displays "spites" on the screen. Sprites are graphics
that can be moved smoothly in any direction and changed in pattern, size and color. CALL
SPRITE and the other statements related to sprites are discussed later in this chapter.
In addition to displaying characters and data on the screen, you can change the color of the
screen and the colors of the characters. CALL SCREEN sets the screen color. CALL COLOR
specifies the foreground and background colors of characters or the color of sprites.
CALL SOUND outputs sounds. A wide range of sounds is available. In addition, CALL SAY
(possibly used with CALL SPGET) makes the computer speak if you have a Solid State Speech
TM
Synthesizer attached to your computer.
TI Extended BASIC provides extensive functions and subprograms for handling numbers and
characters. In addition, you may construct your own functions and write your own
subprograms and subroutines.
Functions are TI Extended BASIC language elements that return a value, usually based on
parameters given to the function. Many functions are mathematical in nature; others control
or affect the result or output produced by the statements in which they occur. The TI
Extended BASIC functions are ABS, ASC, ATN, CHR$, COS, EOF, EXP, INT, LEN, LOG, MAX,
MIN. PI,
POS, REC, RND, RPT$, SEG$, SGN, SIN, SQR, STR$, TAB, TAN, and VAL.
19
Click here to
Return to Table of Contents
You can also define your own functions using DEF. Functions are used within TI Extended
BASIC statements.
Built-in Functions
The following briefly discusses each built-in function.
20
Click here to
Return to Table of Contents
User-Defined Functions
DEF is used to define your own functions. Functions up to one line in length may be defined.
with up to one argument. Longer functions may be constructed by having new definitions
refer to previously defined functions.
However, long functions might be more efficiently handled with subroutines or subprograms.
Subroutines
GOSUB and ON...GOSUB are used to call subroutines. A subroutine is a series of statements
designed to perform a task and is normally used in a program when it performs a task several
times. By using GOSUB or ON...GOSUB you do not have to type the same lines of code
several times. The subroutine can use the values of any variable in the program and change
those values.
Built-in Subprograms
Built-in subprograms are TI Extended BASIC elements that perform special functions. They
always are accessed with the CALL statement. The built-in subprograms are CHAR, CHARPAT,
CHARSET, CLEAR, COINC, COLOR, DELSPRITE, DISTANCE, ERR, GCHAR, HCHAR, INIT,
JOYST, KEY, LINK, LOAD, LOCATE, MAGNIFY, MOTION, PATTERN, PEEK, POSITION, SAY,
SCREEN, SOUND, SPGET, SPRITE, VCHAR, and VERSION.
Built-in subprograms perform many different tasks. Some of the subprograms affect the
display and determine what key has been pressed on the keyboard.
21
Click here to
Return to Table of Contents
Built-in subprograms can also define and control sprites.
A third category of built-in TI Extended BASIC subprograms involves sound and speech.
Four built-in subprograms are only used with machine language subprograms obtained from
Texas Instruments or another source written in TMS9900 machine language on another
computer. Machine language subprograms cannot be written on the TI-99/4 Home Computer.
Detailed instructions on the use of INIT, LINK, LOAD, and PEEK are provided with machine
language subprograms.
22
Click here to
Return to Table of Contents
Finally there are some miscellaneous built-in subprograms.
You may write your own subprograms. They are a series of statements designed to perform a
task. They may be used in a program when you expect to perform the task several times or
to perform the same task in several different programs. Using the MERGE option when you
save a subprogram allows it to be included in other programs.
When a subprogram is in a program, it must follow the main program. The structure of a
program must be as follows:
End of Program
23
Click here to
Return to Table of Contents
Subprograms are called by the use of CALL followed by the subprogram's name and an
optional list of parameters and values. The first line of a subprogram is SUB, followed by the
name of the subprogram and optionally followed by a list of parameters.
The subprograms you write are not part of the main program. They cannot use the values of
variables in the main program, so any values that are needed must be supplied by the
parameter list in the CALL statement. Variable names may be duplicates of those in the main
program or other i subprograms without affecting the values of the variables in the main
program or other subprograms. Subprograms may call other subprograms, but must not call
themselves, either directly or indirectly.
SUBEND must be the last statement in a subprogram. When that statement is executed,
control returns to the statement following the statement that called the subprogram. Control
may also be returned by the SUBEXIT statement.
You may highlight important sections of your programs’ output through the use of sounds,
speech, and colors. This "human engineering" makes the program easier and more
interesting to use.
CALL SOUND
SOUND outputs sounds. Tones may be output in lengths of from .001 to 4.25 seconds at
volumes from 0 (loudest) to 30 (softest). The frequency range is from 110 (A below low C) to
44, 733 (above the range of human hearing). In addition, 8 noises are available. Up to three
tones and one noise may be produced at the same time. Appendix D lists the frequencies that
are used to produce the musical notes.
SAY produces speech when a Texas Instruments Solid State Speech TM Synthesizer (sold
separately) is attached to the console. You can choose among 373 letters, numbers, words,
and phrases (listed in Appendix L). In addition, you can construct new words from old by
combining words. For example, SOME + THING produces "something" and THERE + FOUR
produces "therefore".
SPGET is used to retrieve the speech codes that produce speech. These patterns can then be
used to produce more natural speech and can be used to change words. Because making
new words is a complex process, it is not discussed in this manual. However, suffixes can be
added rather simply. Appendix M tells how to add the suffixes ING, S, and ED to any word, so
that words such as ANSWERING, ANSWERS, ANSWERED, INSTRUCTING, INSTRUCTS, and
INSTRUCTED are included in the computer's vocabulary.
24
Click here to
Return to Table of Contents
CALL COLOR and CALL SCREEN
COLOR changes the colors of character sets and determines sprite colors. SCREEN specifies
the color of the screen as one of the sixteen colors available on the TI-99/4 Home Computer.
SPRITES
Sprites are graphics that can be displayed and moved on the screen. One advantage that
sprites have over other characters is that they can be at any of 49,152 positions of 192 rows
and 256 columns rather than one of the 768 positions of 24 rows and 32 columns used by
statements such as CALL VCHAR and CALL HCHAR. Because of this greater resolution, sprites
can move more smoothly than characters. Also, once set in motion, sprites can continue to
move without further program control.
CALL SPRITE
CALL SPRITE defines sprites. This subprogram specifies the character pattern that sprites use,
their color, their position, and, optionally, their motion.
Although you may use any of the predefined characters, numbers 32 through 95, as a sprite,
CALL CHAR is generally used to define a new pattern for a sprite. Up to four 8 by 8 dot
characters may be used to form a sprite. The MAGNIFY subprogram controls the resolution
and size of sprites.
Once a sprite is set up, it can be altered by various subprograms. COLOR changes the color of
a sprite. LOCATE moves the sprite to a new position. PATTERN changes the character that
defines a sprite. MOTION alters the motion of a sprite.
Three subprograms provide information about sprites while a program is running. COINC
returns a value that indicates if sprites or a sprite and a point on the screen are at or near the
same place on the screen. DISTANCE returns a value that specifies the distance between two
sprites or a sprite and a point on the screen. POSITION returns values that indicate the
position of a sprite.
CALL DELSPRITE
CALL DELSPRITE allows you to delete sprites. If you prefer, you may "hide" sprites by
locating them off the bottom of the screen.
25
Click here to
Return to Table of Contents
DEBUGGING
BREAK causes the computer to stop program execution so that you can print the values of
variables or change their values. BREAK also resets characters to their standard colors (black
on transparent), restores the standard screen color (cyan), restores the standard characters
(32-95) to their standard representation, and deletes sprites.
ON BREAK tells the computer what to do if a break occurs. You can use this statement to tell
the computer to ignore breakpoints that you have entered in the program. CONTINUE causes
the computer to continue program execution after a breakpoint. UNBREAK cancels any
breakpoints set with BREAK. Note: If you have put ON BREAK CONTINUE, the computer will
not stop when you press SHIFT C (CLEAR).
TRACE causes the computer to display each line number before the statement(s) on that line
is (are) executed. Using this statement allows you to follow the sequence of operation of a
program. UNTRACE cancels the operation of TRACE.
ERROR HANDLING
You may include statements in a program to handle errors that occur while the program is
running.
CALL ERR returns information indicating where an error has occurred and what the error is.
Appendix N lists the error codes that are returned. ON ERROR specifies what the computer
does if an error occurs. ON WARNING specifies what the computer does if a condition arises
that would normally cause a warning message to be issued. RETURN is used with ON ERROR
in addition to its use with GOSUB. It repeats execution of the statement that caused the
error, returns to the statement following the one that caused the error, or transfers control to
some other part of the program that avoids the error that has occurred.
26
Click here to
Return to Table of Contents
PROGRAM ENTRY EXAMPLE
Now that you've had a brief overview of the features of TI Extended BASIC, you may enjoy
reviewing or even entering and experimenting with a demonstration program. This section
demonstrates a number of the useful features of TI Extended BASIC. By following the
suggestions in this section, you can learn some useful shortcuts in the entry process.
This program allows you to playa game called Codebreaker. In playing it, you determine the
length of a code (1 to 8 digits). Then you decide the range of digits that may be included in
the code (up to ten). The computer selects the digits in the code without repeating digits. You
then guess what the digits are and their sequence. After each guess, the computer tells you
how many digits you guessed correctly and how many are in the correct place. (If you repeat
a digit in your guess, it is counted as right each time it appears.) Using this information, you
guess again. You win when you guess all the digits correctly and place them in the proper
sequence.
For example, suppose you've chosen to play the game using four digits with each digit being
anyone of nine numbers (0, 1, 2, 3, 4, 5, 6, 7, or 8). The code the computer chooses might
be 0743, which you are trying to break. Here is a possible sequence of guesses.
To begin entering the example, turn on any peripheral devices you have connected to the
computer. Insert the TI Extended BASIC Command Module and turn on the computer. Press
any key to go to the master selection list. Press 3 to select TI Extended BASIC.
In the following, the characters you type and the keys you press are UNDERLINED.
27
Click here to
Return to Table of Contents
CODEBREAKER Program Entry DISPLAY
COMMENTS * READY *
28
Click here to
Return to Table of Contents
Displays the program as it is >LIST ENTER
currently entered. 100 REM CODEBREAKER X BASIC
110 DIM CODE$(8),GUESS$(8)
120 RANDOMIZE
130 DISPLAY AT(11,9)BEEP ERASE ALL:
"CODEBREAKER "
140 DISPLAY AT (19,1)BEEP:"NUMBER OF
CODES? (1 -8)"
150 DISPLAY AT(21,6)BEEP: "DIGITS
EACH CODE?"
160 ACCEPT
AT(19,24)VALIDATE(DIGIT):CODES
170 ACCEPT
AT(21,24)VALIDATE(DIGIT):DIGITS
CODEBREAKER
Screen clears, then this appears:
NUMBER OF CODES? (1 -8)
Enter anything except a digit. The computer beeps and does not accept it. Enter 4. The
cursor moves down to the second prompt. Enter 10. The program ends and you can continue
entry.
29
Click here to
Return to Table of Contents
Starts the loop to choose the codes. >190 FOR A=1 TO CODES !CHOOSE CODES ENTER
The words after the exclamation point
are a comment.
Chooses codes at random. >200 CODE$(A)=STR$(INT(RND*DIGITS)) ENTER
Starts the loop to prevent duplicate >210 FOR B=0 TO A -1 !CHECK FOR
DUPLICATES ENTER
codes. >220 IF CODE$(A)=CODE$(B) THEN 200 ENTER
Checks for duplicates. Chooses a new
code if there is a duplicate. >230 NEXT B ENTER
Finishes duplicate check loop. >240 NEXT A ENTER
Finishes code choice loop. >250 ROW=2 ENTER
30
Click here to
Return to Table of Contents
Completes inside loop. >370 NEXT F ENTER
Completes outside loop. >380 NEXT E ENTER
Displays the number of digits that are >390 DISPLAY AT(ROW,14):RIGHT ENTER
correct.
REDO line 390 to be: 400 DISPLAY AT >400 SHIFT-R
(ROW,22):PLACE.
400 DISPLAY AT(ROW, 22):PLACE ENTER
Displays the number of digits that are in
the correct place.
Numbers lines starting at 410, >NUM 410 ENTER
Checks to see if the code has been solved. >410 IF PLACE<>CODES THEN
ROW=ROW+1::IF ROW>22 THEN 470 ELSE
If it has, goes to the next line. If it has 280 ENTER
not, adds one to the row. Then if the row
is more than 22, goes to line 470 and
gives the solution. Otherwise, returns to
line 280 to accept another guess.
Displays the win message with the >420 DISPLAY AT(23,1)BEEP:"YOU WIN
number of guesses at the 23rd row WITH";ROW-1;"GUESSES." ENTER
starting at the first column. ,
REDO line 420 to be: 430 DISPLAY >430 ENTER
AT(24,1) BEEP:"PLAY AGAIN? (Y/N) Y",
Displays the prompt PLAY AGAIN? (Y/N) Y 430 DISPLAY AT(24,1)BEEP: "PLAY
at the 24th row starting at the first AGAIN? (Y/N) Y " ENTER
column. >NUM 440 ENTER
Numbers lines starting at 440.
Accepts an entry into X$ on the 24th row, >440 ACCEPT AT(24,19)SIZE(-1)BEEP
19th column, Does not remove any VALIDAT E( "YN"):X$ ENTER
character that is already there (in this
case, a Y from the DISPLAY statement in
line 430), accepts only one character,
beeps, and accepts only Y or N. Pressing
ENTER at this point when the program is
running confirms the Y that was displayed
by line 430.
If Y is entered, returns to line 190 and >450 IF X$="Y" THEN 190 ENTER
chooses a new code for another game.
Stops the program. >460 STOP ENTER
31
Click here to
Return to Table of Contents
Displays the message THE CODE IS at the >470 DISPLAY AT(23,1)BEEP: "THE CODE
23rd row, 1st column. IS" ! LOSE, GIVE UP, OR RESET ENTER
Begins a loop to display the digits. >480 FOR G=1 TO CODES ENTER
Displays the digits. >490 DISPLAY AT(23,12+G):CODE$(G) ENTER
32
Click here to
Return to Table of Contents
Before running a program, you should proofread it. Here is a list of the entire program for
you to check against your program list.
33
Click here to
Return to Table of Contents
310 GUESS$(D)=SEG$(C$,D,1)
320 NEXT D
330 RIGHT,PLACE=0
340 FOR E=1 TO CODES !CHECK GUESS
350 FOR F=1 TO CODES
360 IF CODE$(E)=GUESS$(F) THEN
RIGHT=RIGHT+1::IF E=F THEN
PLACE=PLACE+1
370 NEXT F
380 NEXT E
390 DISPLAY AT(ROW,14):RIGHT
400 DISPLAY AT(ROW,22):PLACE
410 IF PLACE<>CODES THEN ROW
=ROW+1::IF ROW>22 THEN 470 ELSE 280
420 DISPLAY AT(23,1)BEEP:"YOU WIN
WITH";ROW-1;"GUESSES. "
430 DISPLAY AT(24,1)BEEP:"PLAY AGAIN?
(Y/N) Y"
440 ACCEPT AT(24,19)SIZE(-1)BEEP
VALIDATE("YN"):X$
450 IF X$="Y" THEN 190
460 STOP
470 DISPLAY AT(23,1)BEEP: "THE CODE
IS" ! LOSE, GIVE UP, OR RESET
480 FOR G=1 TO CODES
490 DISPLAY AT(23,12+G):CODE$(G)
500 NEXT G
510 DISPLAY AT(24,1)BEEP: "PLAY
AGAIN? (Y/N) Y"
520 ACCEPT AT(24,19)SIZE(-1) BEEP
VALIDATE("YN") :X$
530 IF X$="Y" THEN 130
34
Click here to
Return to Table of Contents
Now run the program by typing RUN and pressing ENTER. Choose 4 codes with 10 digits (0,
1, 2, 3, 4, 5, 6, 7, 8, and 9) possible in each code. Guessing the code in six tries is excellent.
Finding it in eight is very good.
If you wish to use the program again, save it on diskette or cassette. To save it on cassette,
make sure the cassette player is connected. Then enter SAVE CS1 and follow the instructions
that appear on the screen.
To save the program on diskette, enter SAVE DSK1.filename with whatever filename you wish
to use to save it, such as CODEBREAK.
After saving the program, or if you do not wish to save the program, enter NEW. The
program is removed and you may enter another program.
If you have saved the program, you can easily reload it into the computer's memory for reuse
or further editing. Reload the program from a cassette by entering OLD CS1 and then
following the instructions that appear on the screen. Reload the program from diskette by
entering OLD DSK1.filename using whatever filename you used to save it.
When you have finished using TI Extended BASIC, enter BYE to return to the master title
screen.
35
Click here to
Return to Table of Contents
(This page intentionally left blank)
36
Click here to
Return to Table of Contents
TI Extended BASIC Conventions
The chapter discusses the format that TI Extended BASIC programs must take and the ways
in which TI Extended BASIC functions.
37
Click here to
Return to Table of Contents
RUNNING A PROGRAM ON POWERUP
If a program named LOAD is on the diskette in disk drive 1 when TI Extended BASIC is
chosen, that program is loaded and run. The effect is the same as if you had entered RUN
"DSK1.LOAD". If the program does not exist, there is a momentary delay while TI Extended
BASIC looks for it.
FILES
Files are groups of data put on external devices. The most common files are on cassettes or
diskettes, but data sent through external devices such as the RS232 Interface and the
optional thermal printer, are also considered to be files by TI Extended BASIC.
LINE NUMBERS
Line numbers are required in TI Extended BASIC programs. Line numbers specify the order in
which lines are executed and are used to identify what lines to execute next when using IF-
THEN-ELSE, GOTO, GOSUB, ON ERROR, ON...GOTO, and ON...GOSUB. Line numbers may
also be used by BREAK, LIST, NUM, RESTORE, RETURN, and RUN. Line numbers may be any
integer from 1 through 32767.
The computer automatically generates line numbers if you issue the NUM command. When
not followed by a line number, it provides line numbers starting at 100, incrementing each
subsequent line by 10. You may resequence line numbers with the RES command.
LINES
Lines may be up to 140 characters long, including the line number and spaces. If you have
reached the end of a line, additional characters you enter replace the 140th character. It is
possible to make a line longer than 140 characters in the Edit Mode by the use of SHIFT G
(INSERT).
SPECIAL SYMBOLS
Special symbols separate statements and remarks on the same line. A line of TI Extended
BASIC consists of a line number, one or more TI Extended BASIC statements, and an optional
remark. For example:
100 FOR A= 1 TO 100::PRINT A;SQR(A)::NEXT A !PRINT SQUARE ROOTS
The statement separator symbol, a double colon (::), is used to separate statements on the
same line. The tail remark symbol, an exclamation point (!), is used to separate an
explanatory remark from the rest of the line. Remarks are not executed when the program is
run.
38
Click here to
Return to Table of Contents
SPACES
Spaces are required in TI Extended BASIC between the elements that make statements to
enable the computer to distinguish variable names from TI Extended BASIC elements.
However, spaces are not required before or after relational symbols or before or after the tail
remark symbol or the statement separator symbol. You may insert extra spaces when
inputting commands and statements, but they are deleted by TI Extended BASIC. When
listing programs, TI Extended BASIC may add spaces around the tail remark symbol and
statement separator symbol.
NUMERIC CONSTANTS
Numeric constants may be entered with any number of digits. However, they tare rounded to
13 or 14 digits by the computer due to the internal storage method used by the computer,
and are normally displayed as a maximum of 10 digits. For extremely large or small numbers,
it is usually more convenient to use scientific notation to enter numbers. The computer
normally uses scientific notation when printing very large or small numbers.
In scientific notation, a number is given as a mantissa (a number with one place to the left of
the decimal point) times 10 raised to an integer power. 15 is expressed in scientific notation
as 1.5x 101. 150 is expressed as 1.5x102; -1,500 is expressed as - 1.5 x 103;
156,789,000,000.000 is expressed as 1.56789 x 1014; and 0.156789 is expressed as 1.56789x
10-1. In TI Extended BASIC, the "x10" is represented by "E". Thus 1.5 x 103 becomes 1.5E3.
Numeric constants are defined in the range - 9.9999999999999E127 to -1E-128, 0, and 1E-
128 to 9.9999999999999E127. If the exponent of a calculated number is greater than 99,
then ** is normally printed or displayed as the power. The entire exponent is kept internally
and can be displayed with a USING clause in a PRINT or DISPLAY statement.
STRING CONSTANTS
String constants in TI Extended BASIC can be up to one input line long. If the string is
enclosed in quotation marks, quotation marks in the string are represented by double
quotation marks.
VARIABLES
Variables in TI Extended BASIC may consist of one to 15 characters. The first character of a
variable must be a letter of the alphabet, the 'at' symbol (@), or an underline (-). Subsequent
characters may be those symbols plus any of the digits. The last character of a string variable
must always be a dollar sign ($). Variables are either scalar or arrays with up to seven
dimensions.
39
Click here to
Return to Table of Contents
Certain words are reserved for use by TI Extended BASIC. They are the commands,
statements, functions and operators that make up the language. These words may not be
used as a variable name, but they make up part of a variable name. The following is a
complete list of words reserved for TI Extended BASIC.
40
Click here to
Return to Table of Contents
NUMERIC EXPRESSIONS
Numeric expressions are constructed from numeric constants, numeric variables, and
functions using the arithmetic operators for addition (+), subtraction (-), multiplication (*),
division (/), and exponentiation (^).
The minus sign (-) can be used either to indicate subtraction or as a unary minus. As a unary
minus, it reverses the sign of what follows it. For example, - 3^2 is equal to - 9 as it is taken
to mean - (3^2).
STRING EXPRESSIONS
String expressions are constructed from string variables, string constants, and function
references using the operation for concatenation (&) to combine strings. If a constructed
string exceeds a length of 255 characters, the extra characters on the right are truncated and
a warning message is issued. The following is an example of concatenation:
RELATIONAL EXPRESSIONS
Relational expressions are most often used in the IF-THEN-ELSE statement, but may be used
anywhere that numeric expressions are allowed. A relational expression has a value of - 1 if it
is true and a value of 0 if it is false. Relational operations are performed, from left to right,
after all arithmetic operations are completed and before string concatenation (the ampersand
operator). The relational expressions are:
41
Click here to
Return to Table of Contents
The following examples illustrate the use of relational expressions:
IF X<Y THEN 200 ELSE GOSUB 420 next >100 IF X<Y THEN 200 ELSE GOSUB
executes line 200 if X is less than Y. If X is 420
greater than or equal to Y, then the
statement GOSUB 420 is executed.
IF L(C)=12 THEN C=S+1 ELSE >100 IF L(C)=12 THEN C=S+1 ELSE
COUNT=COUNT+1:: GOTO 140 sets C equal COUNT=COUNT+1:: GOTO 140
to S plus 1 if L(C) equals 12. If L(C) is not
equal to 12, then COUNT is set to COUNT
plus 1 and line 140 is executed next.
A=2<5 sets A equal to -1 as it is true that 2 >100 A=2<5
is less than 5.
PRINT "THIS"="THAT" prints 0 as it is not >100 PRINT "THIS"="THAT"
true that "THIS" is equal to "THAT".
A=B=7 sets A equal to -1 if B is equal to 7 >100 A=B=7
and to 0 if B is not equal to 7. There is no
effect on B. Note that this is not the same as
the usual arithmetical meaning of A=B=7
LOGICAL EXPRESSIONS
Logical expressions are used with relational expressions. The logical operators are AND, OR,
NOT, and XOR. If true, logical expressions are given a value of -1. If false, they are given a
value of 0. The order of precedence for logical expressions, from highest to lowest, is NOT,
XOR, AND, and OR.
A logical expression using AND is true if both its left and right clauses are true.
A logical expression using OR is true if either its left clause is true, its right clause is true, or
both its left and right clauses are true.
A logical expression using NOT is true if the clause following it is not true.
A logical expression using XOR (exclusive or) is true if either its left or its right clause is true,
but not both its left and right clauses are true.
42
Click here to
Return to Table of Contents
The following examples illustrate the use of logical expressions:
IF 3<4 AND 5<6 THEN L=7 sets L equal to 7 >100 IF 3<4 AND 5<6 THEN L=7
since 3 is less than 4 and 5 is less than 6.
IF 3<4 AND 5>6 THEN L=7 does not set L >100 IF 3<4 AND 5>6 THEN L=7
equal to 7 because 3 is less than 4, but 5 is
not greater than 6.
IF 3<4 OR 5>6 THEN L=7 sets L equal to 7 >100 IF 3<4 OR 5>6 THEN L=7
because 3 is less than 4.
IF 3<4 XOR 5>6 THEN L=7 sets L equal to 7 >100 IF 3<4 XOR 5>6 THEN L=7
because 3 is less than 4 and 5 is not greater
than 6.
IF 3<4 XOR 5<6 THEN L=7 does not set L >100 IF 3<4 XOR 5<6 THEN L=7
equal to 7 because 3 is less than 4 and 5 is
less than 6.
IF NOT 3=4 THEN L=7 sets L equal to 7 >100 IF NOT 3=4 THEN L=7
because 3 is not equal to 4.
IF NOT 3=4 AND (NOT 6=5 XOR 2=2) THEN >100 IF NOT 3=4 AND (NOT 6=3 XOR
200 does not pass control to line 200 2=2) THEN 200
because while it is true that 3 is not equal to
4, it is true that both 6 is not equal to 5 and
2 is equal to 2, so the clause in parentheses
is not true.
IF (A OR B) AND (C XOR D) THEN 200 >100 IF (A OR B) AND (C XOR D)
passes control to line 200 if either A or B or THEN 200
both A and B are true (equal to -1) and C or
D but not both C or D are true (equal to -1)
The logical operators can also be used directly on numbers. They convert the numbers to
binary notation, perform the designated operation on a bit level, and then convert the result
back to decimal representation. A more detailed discussion of the use of logical operators
with numbers can be found in a mathematics or engineering text dealing with logic.
The numbers must be from -32.768 to 32.767, represented in binary notation as from
1000000000000000 to 0111111111111111, with negative numbers given in 2’s complement
form signified by a 1 in the most significant bit. In binary notation, each place is an additional
power of 2 rather than an additional power of 10 as in decimal notation. The following shows
numbers in both decimal and binary notation.
43
Click here to
Return to Table of Contents
The above is the equivalent to:
110=00000000000000012 2510=00000000000110012=110012
610=00000000000001102 -1310=11111111111100112
AND places a 1 in the corresponding binary position if there is a 1 in both the number
preceding and following it. Otherwise it places a zero.
The following illustrate the result of the logical operators when used on numbers.
44
Click here to
Return to Table of Contents
Reference Section
This chapter is an alphabetical list of all of the TI Extended BASIC commands, statements,
and functions, with a detailed explanation of how each works. Examples and sample
programs are included wherever necessary for clarity.
In the format of the elements, key words are CAPITALIZED. Variables are in italics. Optional
portions are enclosed in [brackets]. Items that may be repeated are indicated by ellipses (...).
Alternative forms are presented one above the other.
Appendix A contains a list of the illustrative programs. The Index gives the pages on which
each TI Extended BASIC element is used in an illustrative program.
45
Click here to
Return to Table of Contents
ABS
Format
ABS( numeric-expression )
Description
Examples
46
Click here to
Return to Table of Contents
ACCEPT
Format
Description
The ACCEPT statement suspends program execution until data is entered from the keyboard.
Many options are available with ACCEPT, making it far more versatile than INPUT. It may
accept data at any screen position, make an audible tone (beep) when ready to accept the
data, erase all characters on the screen before accepting data, limit data accepted to a
certain number of characters, and limit the type of characters accepted.
Options
AT(row, column) places the beginning of the input field at the specified row and column.
Rows are numbered 1 through 24. Columns are numbered 1 through 28 with column 1
corresponding to what is called column 3 in the VCHAR, HCHAR, and GCHAR subprograms.
BEEP sounds a short tone to signal that the computer is ready to accept input.
ERASE ALL fills the entire screen with the blank character before accepting input.
If the ACCEPT statement is used without the AT clause, the last two characters on the screen
(at the lower right) are changed to "edge characters" (ASCII code 31).
47
Click here to
Return to Table of Contents
Examples
>100 ACCEPT AT(5,7):Y
ACCEPT AT(5, 7):Y accepts data at the fifth
row, seventh column of the screen into the
variable Y.
>100 ACCEPT VALIDATE("YN") :R$
ACCEPT VALIDATE("YN"):R$ accepts Y or N
into the variable R$.
>100 ACCEPT ERASE ALL:B
ACCEPT ERASE ALL:B accepts data into the
variable B after putting the blank character
into all screen positions,
>100 ACCEPT AT(R,C)SIZE(FIELD
ACCEPT AT(R,C)SIZE(FIELDLEN) BEEP LEN)BEEP VALIDATE(DIGIT,
VALIDATE(DIGIT,"AYN"):X$ accepts a digit "AYN"):X$
or the letters A, Y, or N into the variable X$.
The length of the input may be up to
FIELDLEN characters. The data is accepted
at row R, column C, and a beep is sounded
before data is accepted,
Program
>100 DIM NAME$(20),ADDR$(20)
>110 DISPLAY AT(5,1)ERASE ALL
The program at the right illustrates a typical :"NAME:"
use of ACCEPT, It allows entry of up to 20 >120 DISPLAY AT(7,1):"ADDRESS:"
names and addresses, and then displays
them all. >130 DISPLAY AT(23,1):"TYPE A ?
TO END ENTRY."
>140 FOR S=1 TO 20
>150 ACCEPT
AT(5,7)VALIDATE(UALPHA, "?")BEEP
SIZE(13):NAME$(S)
>160 IF NAME$(S)="?" THEN 200
>170 ACCEPT AT(7,10)SIZE(12):
ADDR$(S)
>180 DISPLAY AT(7,10):"
"
48
Click here to
Return to Table of Contents
>190 NEXT S
>200 CALL CLEAR
>210 DISPLAY AT(1,1):"NAME","ADDRESS"
>220 FOR T=1 TO S-1
>230 DISPLAY AT(T+2,1):NAME$(T),ADDR$(T)
>240 NEXT T
>250 GOTO 250
49
Click here to
Return to Table of Contents
ASC
Format
ASC(string-expression )
Description
The ASC function gives the ASCII character code which corresponds to the first character of
string-expression. A list of the ASCII codes is given in Appendix C. The ASC function is the
inverse of the CHR$ function.
Examples
50
Click here to
Return to Table of Contents
ATN
Format
ATN( numeric-expression )
Description
The ATN function returns the measure of the angle (in radians) whose tangent is numeric-
expression. If you want the equivalent angle in degrees, multiply by 180/PI. The value given
by the ATN function is always in the range –PI/2 < ATN(X) < PI/2.
Examples
51
Click here to
Return to Table of Contents
BREAK
Format
BREAK [line-number-list]
Description
The BREAK command requires a line-number-list. It causes the program to stop immediately
before the lines in line-number-list are executed. After a breakpoint is taken because the line
is listed in line-number-list, the breakpoint is removed and no more breakpoints occur at that
line unless a new BREAK command or statement is given.
The BREAK statement without line-number-list causes the program to stop when it is
encountered. The line at which the program stops is called a breakpoint. Every time a BREAK
statement without line-number-list is encountered, the program stops even if an ON BREAK
NEXT statement has been executed.
You can also cause a breakpoint in a program by pressing SHIFT C (CLEAR) while the
program is running, unless breakpoints are being handled in some other way because of the
action of ON BREAK.
BREAK is useful in finding out why a program is not running exactly as you expect it to. When
the program has stopped you can print values of variables to find out what is happening in
the program. You may enter any command or statement that can be used as a command. If
you edit the program, however, you cannot resume with CONTINUE.
A way to remove breakpoints set with BREAK followed by line numbers is the UNBREAK
command. Also, if a breakpoint is set at a program line and that line is deleted, the
breakpoint is removed. Breakpoints are also removed when a program is saved with the SAVE
command. See ON BREAK for a way to handle breakpoints.
Whenever a breakpoint occurs, the standard character set is restored. Thus any standard
characters that had been redefined by CALL CHAR are restored to the standard characters. A
breakpoint also restores the standard colors, deletes sprites, and resets sprite magnification
to the default value of 1.
Options
The line-number-list is optional when BREAK is used as a statement, but is required when
BREAK is used as a command. When present, it causes the program to stop immediately
before the lines in line-number-list are executed. After a breakpoint is taken because the line
is listed in line-number-list, the breakpoint is removed and no more breakpoints occur at that
line unless a new BREAK command or statement is given.
52
Click here to
Return to Table of Contents
Examples
53
Click here to
Return to Table of Contents
BYE
Format
BYE
Description
The BYE command ends TI Extended BASIC and returns the computer to the master title
screen. All open files are closed, all program lines are erased, and the computer is reset.
Always use the BYE command instead of SHIFT Q (QUIT) to leave TI Extended BASIC.
SHIFT Q (QUIT) does not close files, which may result in data being lost from external
devices.
54
Click here to
Return to Table of Contents
CALL
Format
Description
The CALL statement transfers control to subprogram-name. The subprogram may be either
one built into TI Extended BASIC such as CLEAR, or one you have written. After the
subprogram is executed, the next statement after the CALL statement is executed. CALL may
be either a statement or a command for calling built-in TI Extended BASIC subprograms, but
must be a statement when calling subprograms that you write.
Options
The parameter-list is defined according to the subprogram you are calling. Some require no
parameters at all, some require parameters, and some have optional parameters. Each built-
in subprogram is discussed under its own entry in this manual. The subprograms you can
write are discussed in the section in Chapter II on subprograms and under SUB. The following
are the subprogram-names of the built-in TI Extended BASIC subprograms.
Program
The program at the right illustrates the use of >100 CALL CLEAR
CALL with a supplied subprogram (CLEAR) in >110 X=4
line 100 and the use of a written subprogram >120 CALL TIMES(X)
(TIMES) in line 120. >130 PRINT X
>140 STOP
>200 SUB TIMES(Z)
>210 Z=Z*PI
>220 SUBEND
>RUN
--screen clears
55
Click here to
Return to Table of Contents
12.56637061
56
Click here to
Return to Table of Contents
CHAR subprogram
Format
Description
The CHAR subprogram allows you to define special graphics characters. You can redefine the
standard set of characters (ASCII codes 32-95) and the undefined characters, ASCII codes
96-143. Note that fewer program defined characters are available in TI Extended BASIC than
in TI BASIC, where ASCII codes 96-156 are allowed. The CHAR subprogram is the inverse of
the CHARPAT subprogram.
Character-code specifies the character which you wish to define and must be a numeric
expression with a value from 32 through 143. Pattern-identifier is a 0 through 64 character
string expression which specifies the pattern of the character(s) you are defining. This string
expression is a coded representation of the dots which make up a character on the screen.
LEFT RIGHT
BLOCKS BLOCKS
ROW 1
ROW 2
ROW 3
ROW 4
ROW 5
ROW 6
ROW 7
ROW 8
ANY ROW
LEFT RIGHT
BLOCKS BLOCKS
Each character in the pattern-identifier describes the pattern in one block of one row. The
rows are described from left to right and from top to bottom. Therefore the first two
characters in the pattern-identifier describe the pattern for row one of the grid, the next two
the second row, and so on.
57
Click here to
Return to Table of Contents
Characters are created by turning some dots "on" and leaving others "off". The space
character (ASCII code 32) is a character with all the dots turned "off". Turning all the dots
"on" produces a solid block. The color of the on dots is the foreground color. The color of the
off dots is the background color.
All the standard characters are set with the appropriate dots on. To create a new character,
you specify what dots to turn on and leave off. In the computer a binary code, one number
for each of the 64 dots, is used to specify which dots are on and off in a particular block. A
more human readable form of binary is hexadecimal. The following table shows all the
possible on/off conditions for the four dots in a given block, and the binary and hexadecimal
codes for each condition.
If the pattern-identifier is less than 16 characters, the computer assumes that the remaining
characters are zeros. If the pattern-identifier is 17 to 32 characters, two character-codes are
defined, the first with the first through sixteenth characters and the second with the
remaining characters, with zeros added as needed. If the pattern-identifier is 33 to 48
characters, three character-codes are defined, the first with the first through sixteenth
characters, the second with the seventeenth through thirty-second characters, and the third
with the remaining characters, with zeros added as needed. If the pattern-identifier is 49 to
64 characters, four character-codes are defined, the first with the first through sixteenth
characters, the second with the seventeenth through thirty-second characters, the third with
the thirty-third through forty-eighth characters, and the fourth with the remaining characters,
with zeros added as needed. If the pattern-identifier is longer than 64 characters or is long
enough to define characters higher than character code 143, the excess is ignored.
58
Click here to
Return to Table of Contents
Programs
"1898FF3D3C3CE404"
59
Click here to
Return to Table of Contents
CHARPAT subprogram
Format
Description
The CHARPAT subprogram returns in string-variable the 16-character pattern identifier that
specifies the pattern of character-code. The CHARPAT subprogram is the inverse of the CHAR
subprogram. See the CHAR subprogram for an explanation of the value returned in string-
variable.
Example
60
Click here to
Return to Table of Contents
CHARSET subprogram
Format
CALL CHARSET
Description
The CHARSET subprogram restores the standard character patterns and standard colors for
characters 32 through 95. Normally when a program is run by another program using RUN as
a statement, characters 32 through 95 are not reset to their standard patterns and colors.
CHARSET is useful when this feature is not desired.
Example
CHR$
Format
CHR$(numeric-expression )
Description
The CHR$ function returns the character corresponding to the ASCII character code specified
by numeric-expression. The CHR$ function is the inverse of the ASC function. A list of the
ASCII character codes for each character in the standard character set is given in Appendix C.
Examples
Program
61
Click here to
Return to Table of Contents
CLEAR subprogram
Format
CALL CLEAR
Description
The CLEAR subprogram is used to clear (erase) the entire screen. When the CLEAR
subprogram is called, the space character (ASCII code 32) is placed in all positions on the
screen.
Programs
When the program at the right is run, the >100 CALL CLEAR
screen is cleared before the PRINT >110 PRINT "HELLO THERE!"
statements are performed. >120 PRINT "HOW ARE YOU?"
>RUN
--screen clears
HELLO THERE!
HOW ARE YOU?
62
Click here to
Return to Table of Contents
CLOSE
Format
Description
The CLOSE statement stops a program's use of the file referenced by #file-number. After the
CLOSE statement is performed, the file cannot be used by the program unless you OPEN it
again. The computer no longer associates the #file-number with the closed file, so you can
assign that number to another file.
When no program is running, the following actions close all open files:
If you use SHIFT Q (QUIT) to leave TI Extended BASIC, the computer does not close any
open files, and you may lose data on any files that are open. To avoid this possibility, you
should leave TI Extended BASIC with BYE instead of SHIFT Q (QUIT).
Options
You may delete a diskette file at the same time you close it by adding ":DELETE" to the
statement. Other devices, such as cassette recorders, do not allow DELETE. The manual for
each device discusses the use of DELETE.
63
Click here to
Return to Table of Contents
Examples
64
Click here to
Return to Table of Contents
COINC subprogram
Format
Description
The COINC subprogram detects a coincidence between a sprite and another sprite or a
position on the screen. The value returned in numeric-variable is -1 if there is a coincidence
and 0 if there is no coincidence.
If the keyword ALL is given, the coincidence of any two sprites is reported. If two sprites are
identified by #sprite-number, their coincidence is reported. If #sprite-number and a location
are identified, their coincidence is reported.
If the keyword ALL is given, sprites are coincident only if one or more of the dots which make
them up occupy the same position on the screen. If two sprites or a sprite and a location are
given, then tolerance must be specified, and two sprites are coincident if their upper left hand
corners are within the value specified by tolerance. A sprite and a location are coincident if
the upper left hand corner of the sprite and the position specified by dot-row and dot-column
are within the value specified by tolerance. These coincidents are reported even if there is no
apparent overlap of the sprites or the sprite and the position.
Dot-row and dot-column are numbered consecutively starting with 1 in the upper left hand
corner of the screen. Thus the dot-row can be from 1 to 192 and the dot-column can be from
1 to 256, (Actually the dot-row can go up to 256, but the positions from 193 through 256 are
off the bottom of the screen.) If any part of the sprite occupies the position given, then there
is a coincidence.
Whether or not a coincidence is detected depends on several variables. If the sprites are
moving very quickly, COINC may not be able to detect their coincidence. Also, COINC checks
for a coincidence only when it is called, so a program may miss a coincidence that occurs
when the program is executing some other statement.
65
Click here to
Return to Table of Contents
Program
The program at the right defines two sprites >100 CALL CLEAR
that consist of a triangle. >110 S$="0103070F1F3F7FFF"
>120 CALL CHAR(96,S$)
>130 CALL CHAR(100,S$)
>140 CALL SPRITE(#1,96,7,8,8)
Line 160 shows a coincidence because the >150 CALL SPRITE(#2,100,5,1,1)
>160 CALL COINC(#1,#2,10,C)
sprites are within 10 dots of each other.
>170 PRINT C
Line 180 shows no coincidence because the >180 CALL COINC(ALL,C)
shaded areas of the sprites are not coincident. >190 PRINT C
>RUN
-1
0
66
Click here to
Return to Table of Contents
COLOR subprogram
Format
Description
The COLOR subprogram allows you to specify either a foreground-color for #sprite-number or
a foreground-color and background-color for characters in the character-set. In a given CALL
COLOR, you may define sprite color(s) or character set colors, but not both.
Each character has two colors. The color of the dots that make up the character itself is called
the foreground-color. The color that occupies the rest of the character position on the screen
is called the background-color. In sprites, the background-color is always code 1, transparent,
which allows characters and the screen color to show through. To change the screen color,
see the SCREEN subprogram. Foreground-color and background-color must have values from
1 through 16. The color codes are shown below:
Until CALL COLOR is performed, the standard foreground-color is black (code 2) and the
standard background-color is transparent (code 1) for all characters. Sprites have their color
assigned when they are created. When a breakpoint occurs, all characters are reset to the
standard colors.
67
Click here to
Return to Table of Contents
To use CALL COLOR you must also specify to which of t he fifteen character sets the character
belongs. (Note that TI BASIC has sixteen character sets while TI Extended BASIC has fifteen.)
The list of ASCII character codes for the standard characters is given in Appendix C. The
character-set numbers are given below:
Examples
68
Click here to
Return to Table of Contents
CONTINUE
Format
CONTINUE
CON
Description
The CONTINUE command restarts a program which has been stopped by a breakpoint. It
may be entered whenever a program has stopped running because of a breakpoint caused by
the BREAK command or statement or SHIFT C (CLEAR). However, you cannot use the
CONTINUE command if you have edited a program line. CONTINUE may be abbreviated as
CON.
When a breakpoint occurs, the standard character set and standard colors are restored.
Sprites cease to exist. CONTINUE does not restore standard characters that have been reset
or any colors. Otherwise, the program continues as if no breakpoint had occurred.
69
Click here to
Return to Table of Contents
COS
Format
COS(radian-expression )
Description
The cosine function gives the trigonometric cosine of radian-expression. If the angle is in
degrees, multiply the number of degrees by PI/180 to get the equivalent angle in radians.
Program
70
Click here to
Return to Table of Contents
DATA
Format
DATA data-list
Description
The DATA statement allows you to store data inside your program. The data, which may be
numeric or string constants, is listed in data-list separated by commas. During program
execution, the READ statement assigns the values in data-list to the variables specified in
variable-list in the READ statement.
DATA statements may be located anywhere in a program. However, the order in which they
appear is important. Data from several DATA statements is read sequentially, beginning with
the first item in the first DATA statement. If a program has more than one DATA statement,
the DATA statements are read in the order in which they appear in the program, unless
otherwise specified by a RESTORE statement. Thus the order in which data appears in the
program normally determines the order in which data is read. DATA statements cannot be
part of multiple statement lines.
Data in data-list must correspond to the type of the variable to which it is assigned in the
READ statement. Thus if a numeric variable is specified in the READ statement, a numeric
constant must be in the corresponding position in the DATA statement. Similarly, if a string
variable is specified, a string constant must be supplied. A number is a valid string, so you
may have a numeric constant in a DATA statement where a string is called for in the READ
statement. If a DATA statement contains adjacent commas, the computer assumes you want
to enter a null string (a string with no characters).
When using string constants in a DATA statement, you may enclose the string in quotes.
However, if the string you include contains a comma, leading spaces, or trailing spaces, you
must enclose the string in quotes. If the string is enclosed in quotes, quotes in the string are
represented by double quotes.
71
Click here to
Return to Table of Contents
Program
The program at the right reads and prints several numeric and string constants. Lines 100
through 130 read five sets of data and print their values. two to a line.
72
Click here to
Return to Table of Contents
DEF
Format
Description
The DEF statement allows you to define your own functions. Function-name may be any
variable name. If you specify a parameter following function-name, the parameter must be
enclosed in parentheses and may be any scalar variable name. If expression is a string,
function-name must be a string variable name, i.e. the last character must be a dollar sign.
The DEF statement must occur at a lower numbered line than any reference to the function it
defines. However a DEF statement may not appear in an IF-THEN-ELSE statement. When the
computer encounters a DEF statement during program execution, it proceeds to the next
statement without taking any action. A function may be used in any string or numeric
expression by using function-name followed by an expression enclosed in parentheses if a
parameter was specified in the DEF statement.
Attempting to print the value of a function with PRINT used as a command does not work if
the Memory Expansion is connected to your computer.
Options
If you specify a parameter for a function, when a reference to the function is encountered in
an expression, its value is assigned to parameter. The value of the function is then
determined using the value of parameter and the values of the other variables in the DEF
statement. If parameter is given in the DEF statement, an argument value must always be
given when referring to the function.
The parameter name used in the DEF statement affects only the DEF statement in which it is
used. This means that it is distinct from any other variable with the same name which
appears elsewhere in the program.
Parameter may not be used as an array. You can use an array element in a function as long
as the array does not have the same name as parameter. For example you may use DEF F(A)
= B(Z) but not DEF F(A) = A(Z).
73
Click here to
Return to Table of Contents
Examples
74
Click here to
Return to Table of Contents
DELETE
Format
DELETE device-filename
Description
The DELETE command allows you to remove a program or data file from the computer's filing
system. Device-filename is a string expression. If a string constant is used, it must be
enclosed in quotes. You may also delete data files by using the keyword DELETE in the
CLOSE statement.
Some devices (such as diskettes) allow deleting files; others (such as cassettes) do not. Read
the manual for the specific device for more information.
Example
Program
The program on the right illustrates a use of >100 INPUT "FILENAME: ":X$
DELETE. >110 DELETE X$
75
Click here to
Return to Table of Contents
DELSPRITE subprogram
Format
Description
The DELSPRITE subprogram removes sprites f rom further access by a program. You may
delete one or more sprites by specifying their numbers preceded by a number sign (#) and
separated by commas, or you may delete all sprites by specifying ALL. After being deleted
with DELSPRITE, a sprite can be recreated with the SPRITE subprogram.
Examples
>100 CALL DELSPRITE(#3)
CALL DELSPRITE(#3) deletes sprite number 3.
CALL DELSPRITE(#4,#3*C) deletes sprite number >100 CALL DELSPRITE(#4,#3*C)
4 and the sprite whose number is found by
multiplying 3 by C.
CALL DELSPRITE(ALL) deletes all sprites. >100 CALL DELSPRITE(ALL)
76
Click here to
Return to Table of Contents
DIM
Format
Description
The DIM statement reserves space in the computer's memory for numeric and string arrays.
You can dimension an array only once in a program. If you dimension an array, the DIM
statement must appear in the program at a lower numbered line than any other reference to
the array. If you dimension more than one array in a single DIM statement, array-names are
separated by commas. Array-name may be any variable name. A DIM statement may not
appear in an IF-THEN-ELSE statement.
You may have up to seven-dimensional arrays in TI Extended BASIC. The number of integers
separated by commas following the array name determines how many dimensions the array
has. The values of the integers determine the number of elements in each dimension.
Space is allocated for an array after you enter the RUN command but before the first
statement is executed. Each element in a string array is a null string and each element in a
numeric array is zero until it is replaced with another value.
The values of the integers determine the maximum value of each subscript for that array. If
you are using an array not defined in a DIM statement, the maximum value of each subscript
is 10. The first element is zero unless an OPTION BASE statement sets the minimum subscript
value to 1. Thus an array defined as DIM A(6) is a one dimensional array with seven elements
unless the zero subscript is eliminated by the OPTION BASE statement.
Examples
77
Click here to
Return to Table of Contents
DISPLAY
Format
Description
The DISPLAY statement displays information on the screen. Many options are available with
DISPLAY, making it far more versatile than PRINT. It may display data at any screen position,
make an audible tone (beep) when displaying data, blank screen positions, and erase all
characters on the screen before displaying data.
Options
AT(row, column) places the beginning of the display field at the specified row and column.
Rows are numbered 1 through 24. Columns are numbered 1 through 28 with column 1
corresponding with what is called column 3 in the VCHAR, HCHAR, and GCHAR subprograms.
If the AT option is not present, data is displayed at row 24, column 1, just as it is with the
PRINT statement.
ERASE ALL fills the entire screen with the blank character before displaying data.
Examples
78
Click here to
Return to Table of Contents
Program
79
Click here to
Return to Table of Contents
DISPLAY
Format
Description
The DISPLAY...USING statement is the same as DISPLAY with the addition of the USING
clause, which specifies the format of the data in variable-list. If string-expression is present, it
defines the format. If line-number is present, it refers to the line number of an IMAGE
statement. See IMAGE for an explanation of how the format is defined.
Examples
80
Click here to
Return to Table of Contents
DISTANCE subprogram
Format
Description
The DISTANCE subprogram returns the square of the distance between two sprites or
between a sprite and a location. The position of each sprite is considered to be its upper left
hand corner. Dot-row and dot-column are from 1 to 256. The squared distance is returned in
numeric-variable.
The number returned is computed as follows: The difference between the dot-rows of the
sprites (or the sprite and the location) is found and squared. Then the difference between the
dot-columns of the sprites (or the sprite and the location) is found and squared. Then the two
squares are added. If the sum is larger than 32767, then 32767 is returned. The distance
between the sprites (or the sprite and the location) is the square root of the value returned.
Examples
CALL DlSTANCE(#3,#4,DIST) sets DlST >100 CALL DISTANCE(#3,#4,DIST)
equal to the square of the distance
between the upper left hand corners of
sprite #3 and sprite #4.
CALL DlSTANCE(#4,18,89,D) sets D >100 CALL DISTANCE(#4,18,89,D)
equal to the square of the distance
between the upper left hand corner of
sprite #4 and position 18, 89.
81
Click here to
Return to Table of Contents
END
Format
END
Description
The END statement ends your program and may be used interchangeably with the STOP
statement. Although the END statement may appear anywhere, it is normally placed as the
last line in a program and thus ends the program both physically and logically. The STOP
statement is usually used in other places that you want your program to halt. In TI Extended
BASIC you are not required to use the END statement. The program automatically stops after
it executes the highest numbered line.
82
Click here to
Return to Table of Contents
EOF
Format
EOF(file-number)
Description
The EOF function is used to test whether there is another record to be read from a file. The
value of file-number indicates the file to be tested and must correspond to the number of an
open file. The EOF function cannot be used with cassettes.
The EOF function always assumes that the next record is going to be read sequentially, even
if you are using a RELATIVE file.
The value that the EOF function provides depends on where you are in the file. If you are not
at the last record of the file, the function returns a value of 0. If you are at the last record of
the file, the function returns a value of 1. If the diskette or other storage medium is full, you
are at the end of the file, and there is no more room for any data, the function returns a
value of -1.
Examples
83
Click here to
Return to Table of Contents
ERR subprogram
Format
Description
The ERR subprogram returns the error-code and error-type of the most recent uncleared
error. An error is cleared when it has been accessed by the ERR subprogram, another error
has occurred, or the program has ended.
Error-codes are two or three digit numbers. The meaning of each of the codes is in Appendix
N.
If error-type is a negative number, then the error was in the execution of the program. If the
error-code is 130 (I/O ERROR), the error-type is a positive number and the number is the
number of the file that caused the error.
Options
You may optionally obtain the error-severity and line-number on which the error occurred.
The error-severity is always 9. The line-number is the number of the line being executed
when the error occurred. It is not always the line that is the source of the problem since an
error may occur because of values generated or actions taken elsewhere in a program.
Examples
84
Click here to
Return to Table of Contents
Program
The program on the right illustrates the use of >100 ON ERROR 130
CALL ERR. An error is caused in line 110 by >110 CALL SCREEN(18)
calling for an illegal screen color. Because of >120 STOP
line: 100, control is transferred to line 130. Line >130 CALL ERR(W,X,Y,Z)
140 prints the values obtained. The 79 >140 PRINT W;X;Y;Z
indicates that a bad value was provided. The - >RUN
>79 -1 9 110
1 indicates that the error was in a statement.
The 9 is the error-severity. The 110 indicates
that the error occurred in line 110.
85
Click here to
Return to Table of Contents
EXP
Format
EXP( numeric-expression )
Description
The EXP function returns the exponential value (ex) of numeric-expression. The value of e is
2.718281828459.
Examples
86
Click here to
Return to Table of Contents
FOR TO [STEP]
Format
Description
The FOR-TO-STEP statement repeats execution of the statements between FOR – TO – STEP
and NEXT until the control-variable is outside the range of initial-value to limit. The FOR-TO-
STEP statement is useful when repeating the same steps in a loop. The FOR-TO-STEP
statement cannot be used in an IF-THEN-ELSE statement.
Control-variable may be any unsubscripted numeric variable. It acts as a counter for the loop.
Initial-value and limit are numeric expressions. The loop starts with control-variable given a
value of initial-value. The second time through the loop, the value of control-variable is
changed by one or optionally by increment, which may be a positive or negative number. This
continues until the value of control-variable is outside the range initial-value to limit. Then the
statement after NEXT is executed. The value of control-variable is not changed when the
computer leaves the loop.
The value of control-variable can be changed within the loop, but this must be done carefully
to avoid unexpected results. Loops may be "nested" that is one loop may be contained wholly
within another. You may leave a loop using GOTO, GOSUB, IF-THEN-ELSE, or the like, and
then return. However, you may not enter a FOR-NEXT loop at any point except at its start.
If initial-value exceeds limit at the beginning of the FOR-NEXT loop, none of the statements in
the loop are executed. Instead execution continues with the first statement after the NEXT
statement.
Examples
87
Click here to
Return to Table of Contents
Program
88
Click here to
Return to Table of Contents
GCHAR subprogram
Format
Description
The GCHAR subprogram reads a character from anywhere on the display screen. The
computer returns in numeric-variable the ASCII code for the character in the position
described by row and column.
Row and column are numeric expressions. A value of 1 for row indicates the top of the
screen. A value of 1 for the column indicates the left side of the screen. The screen can be
thought of as a grid as shown below.
Examples
GOSUB
Format
GOSUB line-number
GO SUB line-number
Description
The GOSUB statement allows transfer to a subroutine. When executed, control is transferred
to line-number and that statement and any following (which may include any statements,
including GOTO statements and other GOSUB statements) are executed. When a RETURN
statement is encountered, control is returned to the next statement following the GOSUB
statement. Subroutines are most useful when the same action is to be performed in different
parts of a program. See also ON...GOSUB. Subroutines in TI Extended BASIC may call
themselves.
Example
90
Click here to
Return to Table of Contents
Program
91
Click here to
Return to Table of Contents
GOTO
Format
GOTO line-number
GO TO line-number
Description
The GOTO statement allows you to transfer control unconditionally to another line within a
program. When a GOTO statement is executed, control is passed to the first statement on the
line specified by line-number.
The GOTO statement should not be used to transfer control into subprograms.
Program
The program at the right shows the use of >100 REM ADD 1 THROUGH 100
GOTO in line 160. Anytime that line is reached >110 ANSWER=0
the program executes line 130 next and >120 NUMB=1
proceeds from that new point. >130 ANSWER=ANSWER+NUMB
>140 NUMB=NUMB+1
>150 IF NUMB>100 THEN 170
>160 GOTO 130
>170 PRINT "THE ANSWER
IS";ANSWER
>RUN
92
Click here to
Return to Table of Contents
HCHAR subprogram
Format
Description
The HCHAR subprogram displays a character anywhere on the display screen and optionally
repeats it horizontally. The character with the ASCII value of character-code is placed in the
position described by row and column and is repeated horizontally repetition times.
A value of 1 for row indicates the top of the screen. A value of 24 is the bottom of the screen.
A value of 1 for column indicates the left side of the screen. A value of 32 is the right side of
the screen. The screen can be thought of as a grid as shown below.
93
Click here to
Return to Table of Contents
Examples
94
Click here to
Return to Table of Contents
IF – THEN – ELSE
Format
Description
Statement1 and statement2 may each be several statements long, separated by the
statement separator symbol. They are only executed if the clause immediately before them is
executed. The IF-THEN-ELSE statement cannot contain DATA, DEF, DIM, FOR, NEXT,
OPTION BASE, SUB, or SUBEND.
Examples
IF X>5 THEN GOSUB 300 ELSE X = X + 5 >100 IF X>5 THEN GOSUB 300 ELSE
operates as follows: If X is greater than 5, then X=X+5
GOSUB 300 is executed. When the subroutine is
ended, control returns to the line following this
line. If X is 5 or less, X is set equal to X + 5 and
control passes to the next line.
IF A>3 THEN 300 ELSE A=0::GOTO 10 operates >100 IF A>3 THEN 300 ELSE A=0
as follows: If A is greater than 3, then control is ::GOTO 10
transferred to line 300. Otherwise, A is reset to
zero and control is transferred to line 10.
95
Click here to
Return to Table of Contents
IFA$="Y" THEN COUNT=COUNT+ 1 >100 IF A$="Y" THEN
::DISPLAY AT(24,1):"HERE WE GO COUNT=COUNT+1::DISPLAY
AGAIN!"::GOTO 300 operates as follows: AT(24,1):"HERE WE GO AGAIN! "::GOTO
If A$ is not equal to "Y", then control 300
passes to the next line. If A$ is equal to
"Y", then COUNT is incremented by 1, a
message is displayed, and control is
transferred to line 300.
96
Click here to
Return to Table of Contents
Program
97
Click here to
Return to Table of Contents
IMAGE
Format
IMAGE format-string
Description
The IMAGE statement specifies the format in which numbers are printed or displayed when
the USING clause is present in PRINT or DISPLAY. No action is taken when the IMAGE
statement is encountered during program execution. The IMAGE statement must be the only
statement on a line. The following description of format-string also applies to the use of an
explicit image after the USING clause in PRINT...USING and DISPLAY...USING.
Format-string must contain 254 or fewer characters and may be made up of any characters.
They are treated as follows:
Pound signs (#) are replaced by the print-list values given in PRINT...USING or
DISPLAY...USING. One pound sign must be allowed for each digit of the value and one for the
negative sign if it is present, or for each character that is to be printed. If there is not enough
room to print the number or characters in the space allowed, each pound sign is replaced
with an asterisk (*), If more numbers are after the decimal place than are allowed by the
number of pound signs after the decimal place in the IMAGE statement, the number is
rounded to fit. If there are fewer non-numeric characters than are allowed for in the print
string, the value printed will have blanks for the extra characters.
To indicate that a number is to be given in scientific notation, circumflexes (^) must be given
for the E and power numbers. There must be four or five circumflexes, and 10 or fewer
characters (minus sign, pound signs, and decimal point) when using the E format.
The decimal point separates the whole and fractional portions of numbers, and is printed
where it appears in the IMAGE statement.
All other letters, numbers, and characters are printed exactly as they appear in the IMAGE
statement.
Each IMAGE statement may have space for many images, separated by any character except
a decimal point. If more values are given in the PRINT...USING or DISPLAY...USING
statement than there are images, then the images are reused, starting at the beginning of
the statement.
If you wish, you may put format-string directly in the PRINT...USING or DISPLAY...USING
statement immediately following USING. However, if a
98
Click here to
Return to Table of Contents
format-string is used often, it is more efficient to refer to an IMAGE statement.
Examples
IMAGE THE ANSWERS ARE ### AND ##.## >200 IMAGE THE ANSWERS ARE ###
allows printing of two numbers. The first may be AND ##.##
from - 99 to 999 and the second may be from - >210 PRINT USING 200:A,B
9.99 to 99.99. The following show how some
sample values will be printed or displayed.
Values Appearance
-99 -9.99 THE ANSWERS
ARE -99 AND -9.99
-7 -3.459 THE ANSWERS ARE -
7 AND -3.46
0 0 THE ANSWERS ARE
0 AND 0.00
14.8 12.75 THE ANSWERS ARE
15 AND 12.75
795 852 THE ANSWERS ARE
795 AND ***
-984 64.7 THE ANSWERS ARE
*** AND 64.70
99
Click here to
Return to Table of Contents
IMAGE DEAR ####, allows printing a four- >300 IMAGE DEAR ####,
character string. The following show how some >310 PRINT USING 300:X$
sample values will be printed or displayed.
Values Appearance
JOHN DEAR JOHN,
TOM DEAR TOM,
RALPH DEAR ****,
$ 233.45
The amounts are printed with the decimal points -147.95
lined up. 8.40
37.26
-51.30
85.20
464.00
------
$ 629.06
100
Click here to
Return to Table of Contents
The program at the right >100 IMAGE ###.##,###.#
shows the effect of using >110 PRINT USING 100:50.34,50.34,37.26,37.26
more values in the >RUN
PRINT...USING statement
than there are images in the 50.34, 50.3
IMAGE statement. 37.26, 37.3
101
Click here to
Return to Table of Contents
INIT subprogram
Format
CALL INIT
Description
The INIT subprogram is used along with LINK, LOAD, and PEEK, to access assembly language
subprograms. The INIT subprogram checks to see that the Memory Expansion is connected,
prepares the computer to run assembly language programs, and loads a set of supporting
routines into the Memory Expansion.
The INIT subprogram must be called before LOAD and LINK are called. INIT removes any
previously loaded subprograms from the Memory Expansion. The effects of INIT last until the
Memory Expansion is turned off and does not need to be called from each program that is
using the subprogram involved.
102
Click here to
Return to Table of Contents
INPUT
Format
(For information on using the INPUT statement with a file, see INPUT with files.)
Description
This form of the INPUT statement is used when entering data from the keyboard. The INPUT
statement suspends program execution until data is entered from the keyboard. The optional
input-prompt may display on the screen what data is expected.
Variable-list contains the variables (scalar or array elements; numeric or string) which are
assigned values when the INPUT statement is executed. The variables are separated by
commas. If a value in variable-list is input, it may later be used as a subscript in the same
INPUT statement.
When inputting string values, they may optionally be enclosed in quotation marks. However,
if you wish to have leading or trailing blanks or commas, the entire string must be enclosed in
quotation marks. If more than one value is to be input, separate the values to be input by
commas.
Options
Examples
103
Click here to
Return to Table of Contents
INPUT J,A(J) first accepts data into J >100 INPUT J,A(J)
and then accepts data into the Jth
element of the array A.
104
Click here to
Return to Table of Contents
INPUT (with files)
Format
(For information on using the INPUT statement to enter data from the keyboard, see INPUT.)
Description
The INPUT statement, when used with files, allows you to read data from files. The INPUT
statement can only be used with files opened in INPUT or UPDATE mode. DISPLAY files may
not have over 160 characters in each record.
File-number and variable-list must be included in the INPUT statement. Record-number may
optionally be included when reading random access (RELATIVE) files from diskettes.
All statements which refer to files do so with a file-number from 0 through 255. File-number
is assigned to a particular file by the OPEN statement. File number 0 is dedicated to the
keyboard and screen of the computer. It cannot be used for other files and is always open.
File-number is entered as a number sign (#) followed by a numeric expression that, when
rounded to the nearest integer, is a number from 0 to 255, and is the number of a file that is
open.
Variable-list is the list of variables into which you want the data from the file to be placed. It
consists of string or numeric variables separated by commas with an optional trailing comma.
Options
You can optionally specify the number of the record that you want to read as record-number.
It can only be specified for diskette files which have been opened as RELATIVE. The first
record of a file is number 0.
105
Click here to
Return to Table of Contents
Examples
INPUT #1:X$ puts into X$ the next value >100 INPUT #1:X$
available in the file that was opened as #1.
INPUT #23:X, A, LL$ puts into X, A, and LL$ >100 INPUT #23:X,A,LL$
the next three values from the file that was
opened as #23.
INPUT #11, REC 44:TAX puts into TAX the >100 INPUT #11,REC 44:TAX
first value of record number 44 of the file
that was opened as #11.
106
Click here to
Return to Table of Contents
Program
107
Click here to
Return to Table of Contents
INT
Format
INT( numeric-expression )
Description
The INT function returns the greatest integer less than or equal to numeric-expression.
Examples
108
Click here to
Return to Table of Contents
JOYST subprogram
Format
CALL JOYST( key-unit, x -return, y-return )
Description
The JOYST subprogram returns data into x-return and y-return based on the position of the
joystick in the Wired Remote Controller (available separately) labelled key-unit. Key-unit is a
numeric expression with a value of 1 through 4. The values 1 and 2 are joysticks 1 and 2.
Values 3 and 4 are reserved for possible future use.
The values returned in x-return and y-return depend on the position of the joystick. The
values returned are shown below. The first value in the parentheses is placed in x-return. The
second value is placed in y-return.
Example
Program
109
Click here to
Return to Table of Contents
KEY subprogram
Format
CALL KEY( key-unit, return-variable, status-variable )
Description
The KEY subprogram assigns the code of the key pressed to return-variable. The value
assigned depends on the key-unit specified. If key-unit is 0, input is taken from the entire
keyboard, and the value placed in return-variable is the ASCII code of the key pressed. If no
key is pressed, return-variable is set equal to - 1. See Appendix C for a list of the ASCII
codes.
If key-unit is 1, input is taken from the left side of the keyboard. If key-unit is 2, input is
taken from the right side of the keyboard. The possible values placed in return-variable are
given in Appendix J. Values of 3, 4, and 5 are reserved for possible future uses.
Status-variable indicates whether a key has been pressed. A value of 1 means a new key was
pressed since the last CALL KEY was executed. A value of - 1 means the same key was
pressed as in the previous CALL KEY. A value of 0 means no key was pressed.
Example
Program
110
Click here to
Return to Table of Contents
LEN
Format
LEN(string-expression )
Description
The LEN function returns the number of characters in string-expression. A space counts as a
character.
Examples
111
Click here to
Return to Table of Contents
LET
Format
Description
The LET statement assigns the value of an expression to the specified variable(s). The
computer evaluates the expression on the right and puts its value into the variable(s) on the
left. If more than one variable is on the left, they are separated with commas. The LET is
optional, and is omitted in the examples in this manual. All subscripts in the variable(s) on the
left are evaluated before any assignments are made.
You may use relational and logical operators in numeric-expression. If the relation or logical
value is true, numeric-variable is assigned a value of - 1. If the relation or logical value is
false, numeric-variable is assigned a value of 0.
Examples
X,Y,Z = 12.4 puts the value 12.4 into X,Y, and >100 X,Y,Z=12.4
Z.
L$,D$,B$ = "B" puts "B" into L$, D$, and B$. >100 L$,D$,B$="B"
112
Click here to
Return to Table of Contents
LINK subprogram
Format
Description
The LINK subprogram is used, along with INIT, LOAD, and PEEK, to access assembly
language subprograms. The LINK subprogram passes control and, optionally, a list of
parameters from a TI Extended BASIC program to an assembly language subprogram.
Subprogram-name is the name of the subprogram to be called. It must have been previously
loaded into the Memory Expansion with the CALL LOAD command or statement. Argument-list
is a list of variables and expressions as required by the specific assembly language
subprogram being called.
113
Click here to
Return to Table of Contents
LINPUT
Format
Description
The LINPUT statement allows the assignment of an entire line, file record, or (if there is a
pending input record) the remaining portion of a file record into, string-variable. No editing is
performed on what is input, so commas, leading and trailing blanks, semicolons, colons, and
quotation marks are placed in string-variable as they are given.
Options
A #file-number may be specified. If the file is in RELATIVE format, a specific record may be
specified with REC. The file must be a DISPLAY-type file. If no file is specified, an input-
prompt may be displayed prior to accepting input from the keyboard.
Examples
Program
114
Click here to
Return to Table of Contents
LIST
Format
Description
The LIST command allows you to display program lines. If LIST is entered with no numbers
following it, the entire program in memory is listed. If a number follows LIST, the line with
that number is listed. If a number followed by a hyphen follows LIST, that line and all lines
following it are listed. If a number preceded by a hyphen follows LIST, all lines preceding it
and that line are listed. If two numbers separated by a hyphen follow LIST, the indicated lines
and all lines between them are listed.
By pressing and holding a key until TI Extended BASIC responds, you may temporarily halt a
listing so that you can look at it on the screen. Press any key again to restart the listing.
Similarly, pressing SHIFT C (CLEAR) stops the listing.
Options
The listing normally is displayed on the screen. If you wish, you can instead direct the list to
some other device, such as the optional thermal printer or RS232 interface, by specifying
device-name.
Examples
LIST 100- lists line 100 and all lines after it. >LIST 100-
LIST -200 lists all lines up to and including line >LIST -200
200.
LIST 100-200 lists all lines from 100 through >LIST 100-200
200.
LIST "TP": -200 lists all lines up to and including >LIST "TP": -200
line 200 on the optional thermal printer.
115
Click here to
Return to Table of Contents
LOAD subprogram
Format
Description
The LOAD subprogram is used, along with INIT, LINK, and PEEK, to access assembly
language subprograms. The LOAD subprogram loads an assembly language object file or
direct data into the Memory Expansion for later execution using the LINK statement.
The LOAD subprogram can specify one or more files from which to load object data or lists of
direct load data, which consists of an address followed by data bytes. The address and data
bytes are separated by commas. Direct load data must be separated by file:field, which is a
string expression specifying a file from which to load assembly language object code.
Flle:field may be a null string when it is used merely to separate direct load data fields. Use of
the LOAD subprogram with incorrect values can cause the computer to cease to function and
require turning it off and back on.
Assembly language subprogram names (see LINK) are included in the file.
116
Click here to
Return to Table of Contents
LOCATE subprogram
Format
Description
The LOCATE subprogram is used to change the location of the given sprite(s) to the given
dot-row(s) and dot-column(s). Dot-row and dot-column are numbered consecutively starting
with 1 in the upper left hand corner of the screen. Dot-row can be from 1 to 192 and dot-
column can be from 1 to 256. (Actually dot-row can go up to 256, but the locations from 193
through 256 are off the bottom of the screen.) The location of the sprite is the upper left
hand corner of the character(s) which define it.
Program
117
Click here to
Return to Table of Contents
LOG
Format
LOG(numeric-expression )
Description
The LOG function returns the natural logarithm of numeric-expression where numeric-
expression is greater than zero. The LOG function is the inverse of the EXP function.
Examples
Program
118
Click here to
Return to Table of Contents
MAGNIFY subprogram
Format
CALL MAGNIFY(magnification-factor )
Description
The MAGNIFY subprogram allows you to specify the size of sprites and how many characters
make up each sprite. All sprites are affected by MAGNIFY. Magnification-factors may be 1, 2,
3, or 4. If no CALL MAGNIFY is in a program, the default magnification-factor is 1.
A magnification-factor of 1 causes all sprites to be single size and unmagnified. This means
that each sprite is defined only by the character specified when the sprite was created and
takes up just one character position on the screen.
A magnification-factor of 2 causes all sprites to be single size and magnified. This means that
each sprite is defined only by the character specified when it was created, but takes up four
character positions on the screen. Each dot position in the character specified expands to
occupy four dot positions on the screen. The expansion from a magnification-factor of 1 is
down and to the right.
119
Click here to
Return to Table of Contents
A magnification-factor of 3 causes all sprites to be double size and unmagnified. This means
that each sprite is defined by four character positions that include the character specified. The
first character is the one specified when the sprite was created if its number is evenly divisible
by four. or the next smallest number that is evenly divisible by four. That character is the
upper left quarter of the sprite. The next character is the lower left quarter of the sprite. The
next character is the upper right quarter of the sprite. The final character is the lower right
quarter of the sprite. The character specified when the sprite was created is one of the four
that makes up the sprite. The sprite occupies four character positions on the screen.
A magnification-factor of 4 causes all sprites to be double size and magnified. This means
that each sprite is defined by four character positions that include the character specified. The
first character is the one specified when the sprite was created if its number is evenly divisible
by four, or the next smallest number that is evenly divisible by four. That character is the
upper left quarter of the sprite. The next character is the lower left quarter of the sprite. The
next character is the upper right quarter of the sprite. The final character is the lower right
quarter of the sprite. The character specified when the sprite was created is one of the four
that makes up the sprite. The sprite occupies sixteen character positions on the screen. The
expansion from a magnification-factor of 3 is down and to the right.
120
Click here to
Return to Table of Contents
Program
The following program illustrates a use of the MAGNIFY subprogram. When it is run, a little
figure appears near the centre of the screen. In a moment, it gets to be twice as big,
covering four character positions. In another moment, it is replaced by the upper left corner
of a larger figure, still covering four character positions. Then the full figure appears, covering
sixteen character positions. Finally it is reduced in size to four character positions.
>220 STOP
>230 REM DELAY
>240 FOR DELAY=1 TO 500
>250 NEXT DELAY
>260 RETURN
121
Click here to
Return to Table of Contents
MAX
Format
Description
The MAX function returns the larger of numeric-expression1 and numeric-expression2. If they
are equal, then their value is returned.
Examples
122
Click here to
Return to Table of Contents
MERGE
Format
Description
The MERGE command merges lines in filename from the given device into the program lines
already in the computer's memory. If a line number in filename duplicates a line number in
the program already in memory, the new line replaces the old line. Otherwise the lines are
inserted in line number order among the lines already in memory. The MERGE command does
not clear breakpoints. Also, MERGE can only be used with diskettes.
NOTE: Files can only be merged into memory if they were saved using the MERGE option.
See the SAVE command for more information.
Example
Program
>SAVE "DSK1.BOUNCE",MERGE
123
Click here to
Return to Table of Contents
On the right is a program you can put >120 CALL CHAR(96,
into the computer's memory. "18183CFFFF3C1818")
>130 CALL SPRITE(#1,96,7,92,1 28)
>150 GOSUB 500
>160 STOP
124
Click here to
Return to Table of Contents
MIN
Format
Description
Examples
125
Click here to
Return to Table of Contents
MOTION subprogram
Format
Description
The MOTION subprogram is used to specify the row-velocity and column-velocity of a sprite.
If both the row- and column-velocities are zero, the sprite is stationary. A positive row-
velocity moves the sprite down and a negative value moves it up. A positive column-velocity
moves the sprite to the right and a negative value moves it to the left. If both row-velocity
and column-velocity are nonzero, the sprite moves smoothly at an angle in a direction
determined by the actual values.
The row- and column-velocities may be from - 128 to 127. A value close to zero is very slow.
A value far from zero is very fast. When a sprite comes to the edge of the screen, it
disappears and reappears in the corresponding position on the other side of the screen.
Program
The program at the right illustrates a use of the >100 CALL CLEAR
MOTION subprogram.
Line 110 creates a sprite. >110 CALL SPRITE(#1,33,5,92,1
24)
Lines 120 and 130 set values for the motion of >120 FOR XVEL=-16 TO 16 STEP 2
the sprite. >130 FOR YVEL=-16 TO 16 STEP 2
Line 140 displays the current values of the >140 DISPLAY AT (12,11):XVEL;
motion of the sprite. YVEL
Lines 160 and 170 complete the loops that set >160 NEXT YVEL
the values for the motion of the sprite. >170 NEXT XVEL
126
Click here to
Return to Table of Contents
NEW
Format
NEW
Description
The NEW command clears the memory and screen and prepares the computer for a new
program. All values are reset and all defined characters become undefined. Any open files are
closed. Characters 32 through 95 are reset to their standard representations. The TRACE and
BREAK commands are cancelled.
Be sure to save the program that you have been working on before you enter NEW as it is
unrecoverable by any means once NEW has been entered.
127
Click here to
Return to Table of Contents
NEXT
Format
NEXT control-variable
See ON BREAK, ON WARNING, and RETURN (with ON ERROR) for the use of NEXT clause
with those statements.
Description
The NEXT statement is always paired with the FOR- TO-STEP statement for construction of a
loop. Control-variable must be the same as control-variable in the FOR- TO-STEP statement.
The NEXT statement may not appear in an IF-THEN-ELSE statement.
The NEXT statement controls when the loop is repeated. Each time the NEXT statement is
executed, control-variable is changed by the value following STEP in the FOR- TO-STEP
statement, or by 1 if there is no STEP clause. If the value of control-variable is between
initial-value and limit, the loop is executed again. If it is not, control passes to the statement
after NEXT. Thus the value of control-variable at the end of the loop is always the first value
outside the range of the FOR- TO-STEP statement. See FOR-TO-STEP for more information.
Program
128
Click here to
Return to Table of Contents
NUMBER
Format
Description
The NUMBER command generates sequenced line numbers, allowing entry of program lines
without typing the line numbers. If initial-line and increment are not specified, the line
numbers start at 100 and increase in increments of 10. You may give the command at any
time in the Command Mode. If a line already exists, the current line is displayed. You may
type over it to replace it, alter it using the edit functions, or press ENTER to confirm it. To
leave the NUMBER mode, press ENTER when a line comes up with no statements on it or
press SHIFT C (CLEAR) when any line is displayed. NUMBER may be abbreviated as NUM.
Options
Example
>115
>LIST
100 X=4
105 Y=7
110 Z=11
120 PRINT (Y+X)/Z
129
Click here to
Return to Table of Contents
OLD
Format
Description
The OLD command loads program-name from device into memory. The program must first
have been put on device using the SAVE command. OLD closes any open files and removes
the program currently in memory before loading program-name. To add program lines from
another program to a program in memory, see the MERGE command.
Device can be several different things. If it is CS1 or CS2, designating one of the two possible
cassette recorders, then no program-name is given. The program loaded is the program that
is on the cassette. Instructions on operating the cassette recorder are displayed on the
screen.
See the Disk Memory System Manual for instructions on using OLD with diskettes.
Examples
130
Click here to
Return to Table of Contents
ON BREAK
Format
ON BREAK STOP
ON BREAK NEXT
Description
The ON BREAK statement determines the action taken if a breakpoint is encountered during
the execution of a program. The default action is STOP, which causes program execution to
halt and the standard breakpoint message to be printed. The alternative is NEXT, which
transfers control to the next line without a breakpoint occurring.
You can use ON BREAK NEXT to have a program ignore breakpoints which you have put in a
program for debugging purposes. (NOTE: ON BREAK NEXT does not have any effect on a
BREAK statement which is not followed by a program line number. The breakpoint will occur
even if the statement ON BREAK NEXT has been executed.) When ON BREAK NEXT is in
effect, the external break, SHIFT C (CLEAR), does not stop a program. In that case only
SHIFT Q (QUIT) can stop the program. SHIFT Q (QUIT) erases the program and returns
you to the main screen and may interfere with the proper operation of some external devices
such as disk drives.
Program
The program on the right illustrates the use of >100 CALL CLEAR
ON BREAK. Line 110 sets a breakpoint in line >110 BREAK 150
150. Line 120 sets breakpoint handling to go to >120 ON BREAK NEXT
the next line. A breakpoint occurs in line 130 in >130 BREAK
spite of line 120. Enter CONTINUE. No >140 FOR A=1 TO 50
breakpoint occurs in line 150 because of line >150 PRINT "SHIFT C IS
DISABLED."
120. SHIFT C (CLEAR) has no effect during the
>160 NEXT A
execution of lines 140 through 160 because of >170 ON BREAK STOP
line 120. Line 170 restores the normal use of >180 FOR A=1 TO 50
SHIFT C (CLEAR). >190 PRINT "NOW IT WORKS."
>200 NEXT A
131
Click here to
Return to Table of Contents
ON ERROR
Format
ON ERROR STOP
ON ERROR line-number
Description
The ON ERROR statement determines the action taken if an error occurs during the execution
of a program. The default action is STOP, which causes the standard error message to be
printed and program execution to halt. The alternative is to give a line-number which
transfers control to that line in case of an error.
Once an error has occurred and control has been transferred, error handling reverts to the
normal action, STOP. If you wish to have any new errors handled differently, an ON ERROR
statement must be executed again.
NOTE: A transfer of control following the execution of an ON ERROR statement acts like the
execution of a GOSUB statement. As with GOTO and GOSUB, you must avoid transfers to and
from subprograms. The most common result of an illegal transfer into a subprogram is a
syntax error on a statement that appears to be correct.
132
Click here to
Return to Table of Contents
Program
Line 170 causes the next error to pass >170 ON ERROR 230
control to line 230. Line 180 finds out >180 CALL ERR(CODE,TYPE,SEVER,LINE)
about the error using CALL ERR.
Line 190 transfers control to line 230 if >190 IF LINE<>130 THEN RETURN 230
the error isn’t in the expected line. Line >200 IF CODE<>74 THEN RETURN 230
200 transfers control to line 230 if the >210 X$="5"
error isn’t the one expected. Line 210 >220 RETURN
changes the value of X$ to an >230 REM UNKNOWN ERROR
acceptable value. Line 220 returns
control to the line in which the error
occurred.
Line 240 reports the nature of the >240 PRINT "ERROR";CODE;" IN LINE";
unexpected error and the program LINE
stops. >RUN
5 SQUARED IS 25
133
Click here to
Return to Table of Contents
ON GOSUB
Format
Description
Examples
134
Click here to
Return to Table of Contents
Program
135
Click here to
Return to Table of Contents
ON GOTO
Format
Description
The ON...GOTO statement transfers control to the line-number in the position corresponding
to the value of numeric-expression. Other than giving a choice, it acts the same as the GOTO
statement, but it is more efficient in that it may require fewer lines of code than using an IF-
THEN-ELSE statement.
Examples
136
Click here to
Return to Table of Contents
Program
137
Click here to
Return to Table of Contents
ON WARNING
Format
ON WARNING PRINT
ON WARNING STOP
ON WARNING NEXT
Description
The ON WARNING statement determines the action taken if a warning occurs during the
execution of a program. The default action is PRINT, which causes the standard warning
message to be printed and the program to continue execution. One alternative is STOP,
which causes the standard warning message to be printed and the program to halt execution.
The other alternative is NEXT which causes the program to continue execution without
printing any message.
Program
The program on the right illustrates the use of >100 CALL CLEAR
ON WARNING.
Line 110 sets warning handling to go to the >110 ON WARNING NEXT
next line.
Line 120 therefore prints the result without any >120 PRINT 120,5/0
message.
Line 130 sets warning handling to the default, >130 ON WARNING PRINT
printing the message and then continuing
execution.
Line 140 therefore prints 140, then the >140 PRINT 140,5/0
warning, and then continues.
Line 150 sets warning handling to print the >150 ON WARNING STOP
warning message and then stop execution.
Line 160 therefore prints 160 and then the >160 PRINT 160,5/0
warning message and then stops. >170 PRINT 170
>RUN
120 9. 99999E+**
140
* WARNING
NUMERIC OVERFLOW IN 140
9. 99999E+**
160
* WARNING
NUMERIC OVERFLOW IN 160
138
Click here to
Return to Table of Contents
OPEN
Format
Description
The OPEN statement prepares a BASIC program to use data files stored on a diskette or
cassette by providing a link between file-number and a file. To set up this link, the OPEN
statement describes a file's characteristics. If the file already exists, the description that is
given in the program must match the actual characteristics of the file. Files on cassettes are
not checked, however, so errors may occur if the characteristics do not match.
File-number must be included in the OPEN statement. Statements which refer to files do so
with a file-number from 0 through 255. File number 0 is the keyboard and screen of the
computer. It cannot be used for other files and is always open. You may assign the other
numbers as you wish, with each file having a different number. File-number is entered as a
number sign (#) followed by a numeric expression that, when rounded to the nearest integer,
is a number from 0 to 255, and is not the number of a file that is already open.
Device must also be included in the OPEN statement. If device is CS1 or CS2, designating one
of the two cassette recorders, then no file-name is given. Instructions on operating the
cassette recorder are displayed on the screen.
If device is DSK1, DSK2, or DSK3, designating one of the three disk drives, then file-name is
the name of a file on the diskette in the given drive. If device is DSK.diskette-name, where
diskette-name is the name of a diskette in one of the drives, then file-name is the name of a
file on the diskette named diskette-name. The computer searches the drives, starting at
DSK1, until it finds the diskette with the given name. Then it looks for .file-name on that
diskette.
The other information may be in any order, or may be omitted. If an item is omitted, the
computer assumes certain defaults, which are described below.
Flle-organization can be either sequential or random. Records in a sequential file are read or
written one after the other. Records in random files can be read or written in any order.
Random files may also be processed sequentially. To indicate which structure the file has,
enter either SEQUENTIAL for sequential files or RELATIVE for random files. You may
optionally specify the initial number of records on a file by following the word SEQUENTIAL or
RELATIVE with a numeric expression. If you do not specify the file-organization, the default is
SEQUENTIAL.
139
Click here to
Return to Table of Contents
File-type may be either DISPLAY or INTERNAL. Files can be written either in human-readable
form, called ASCII (DISPLAY), or in machine-readable form, called binary (INTERNAL). Binary
records may take up less space and are processed more quickly by the computer. However, if
the information is going to be printed or displayed, ASCII format is usually a better choice.
To specify that you wish the file to be in ASCII format, enter DISPLAY. To specify binary
format, enter INTERNAL. If you do not specify a file-type, the default is DISPLAY. Usually
INTERNAL is the best choice when using files on cassettes or diskettes, and DISPLAY is the
best choice when using files on the thermal printer or RS232 Interface.
Open-mode may be UPDATE, INPUT, OUTPUT, or APPEND. The computer may be instructed
that the file may be both read and written on, that it may only be read, that it may only be
written on, or that it may only be added to. However, if the file is marked as protected, it
cannot be written on and may only be opened for input.
To be able both to read from and write to a file, specify UPDATE. To just read from a file,
specify INPUT. To just write to a file, specify OUTPUT. To only add to a file, specify APPEND.
Append mode can only be specified for VARIABLE length records. If you do not specify an
open-mode, the default is UPDATE.
Record-type may be either VARIABLE or FIXED. Files may have records that are all the same
length or that vary in length. If all records are the same length, any that are shorter are
padded to make up the difference. Any that are longer may be truncated to the proper
length. You may specify records of variable length by entering VARIABLE. You specify records
of fixed length by entering FIXED.
If you like, you may specify a maximum length of a record by following VARIABLE or FIXED
with a numeric expression. The maximum record is dependent on the device used. If you do
not specify a record length, the default is 80 for diskettes, 64 for cassettes, 80 for the RS232
interface, and 32 for the thermal printer.
RELATIVE files must have FIXED length records. If you do not specify a record-type for a
RELATIVE file, the default is FIXED.
140
Click here to
Return to Table of Contents
SEQUENTIAL files may be either FIXED or VARIABLE. If you do not specify a record-type for a
SEQUENTIAL file, the default is VARIABLE. A fixed-length file may be reopened for either
SEQUENTIAL or RELATIVE access independent of previous file-organization assignments.
Examples
141
Click here to
Return to Table of Contents
OPTION BASE
Format
OPTION BASE 0
OPTION BASE 1
Description
The OPTION BASE statement sets the lowest allowable subscript of arrays to zero or one. The
default is zero. If an OPTION BASE statement is used, it must have a lower line number than
any DIM statement or reference to any array. There may only be one OPTION BASE
statement in a program, and it applies to all array subscripts. The OPTION BASE statement
may not appear in an IF-THEN-ELSE statement.
Example
142
Click here to
Return to Table of Contents
PATTERN subprogram
Format
Description
The PATTERN subprogram allows you to change the character pattern of sprite without
affecting any other characteristics of the sprite.
Sprite-number specifies the sprite you are using. Character-value may be any integer from 32
to 143. See the CHAR subprogram for information on defining the pattern for characters. See
the MAGNIFY subprogram for more information.
Program
144
Click here to
Return to Table of Contents
PEEK subprogram
Format
Description
The PEEK subprogram is used, along with INIT, LINK, and LOAD, to access assembly
language subprograms. The PEEK subprogram returns values in the variables in numeric-
variable-list that correspond with the values in the byte specified by address and the bytes
following it. PEEK can be used without assembly language subprograms, but the information
obtained is of little use.
Detailed instructions on the use of INIT, LINK, LOAD, and PEEK are included with custom
written programs that may be available on diskette or cassette.
Indiscriminate use of PEEK may cause the computer to "lock up" and require it to be turned
off and back on before further use.
Example
145
Click here to
Return to Table of Contents
PI
Format
PI
Description
Example
146
Click here to
Return to Table of Contents
POS
Format
Description
The POS function returns the position of the first occurrence of string2 in a string1. The
search begins at the position specified by numeric-expression. If no match is found, the
function returns a value of zero.
Examples
Program
147
Click here to
Return to Table of Contents
POSITION subprogram
Format
Description
The POSITION subprogram returns the position of the specified sprite(s) in the given dot-
row(s) and dot-column(s) as numbers from 1 to 256. They are the position of the upper left
corner of the sprite. If the sprite is not defined, dot-row and dot-column are set to zero.
The sprite continues to move after its position is returned, so that must be allowed for. The
distance moved depends on the sprite's speed.
Example
148
Click here to
Return to Table of Contents
PRINT
Format
Description
The PRINT statement allows you to transfer the values of the elements of the optional print-
list to the display screen or optionally to an external file or device. Print-list consists of string
constants, numeric constants, string variables, numeric variables, numeric expressions, string
expressions, and/or the TAB function. Each element in print-list is separated from the others
by a semicolon, a comma, or a colon.
The semicolon, comma, and colon control spacing for the screen or a file opened in DISPLAY
format. A semicolon causes the next element to be placed immediately adjacent to the
previous element. A comma causes the next element of print-list to be put in the next print
field. Each print field is 14 characters long. The number of print fields depends on the record
length of the device being used. On the screen, the print fields are at positions 1 and 15. If
the cursor is past the start of the last print field, the next item is printed on the next line. A
colon causes the next element to be put on the next line or record. To print several blank
lines, you may put several colons after the PRINT statement. However, they must have
spaces between them so they are not confused with the statement separator symbol (::).
A separator may be placed following the last element of print-list, which affects the placement
of the next element of the next PRINT, PRINT...USING, DISPLAY (without AT), or
DISPLAY...USING (without AT) statement written to the same device. It causes the next
output statement to be considered to be a continuation of the current one unless it is a
PRINT statement with a REC clause.
When printing a new line on the screen, everything (except sprites) is scrolled up one line (so
the top line is lost) and the new line is printed at the bottom of the screen.
Options
The #file-number determines the file that is to be printed on. If it is omitted or #0, the
screen is used. Otherwise file-number must be the number of a file that is already open. See
OPEN.
The REC clause is used to specify the record on which you wish to print the elements in print-
list. REC may only be used with files that were opened as RELATIVE files. See OPEN.
149
Click here to
Return to Table of Contents
In printing to INTERNAL format files, the comma and semicolon both place the elements in
print-list adjacent to each other. In DISPLAY format files, the comma and semicolon act as
described above, with the semicolon placing the element adjacent to the previous clement
and the comma putting the element in the next print field.
Examples
PRINT causes a blank line to appear on >100 PRINT
the display screen.
PRINT #12,REC 7:A causes the value of >100 PRINT #12,REC 7:A
A to be printed on the eighth record of
the file that was opened as number 12.
(Record number 0 is the first record.)
150
Click here to
Return to Table of Contents
PRINT #1,REC 3:A,B followed by PRINT >100 PRINT #1,REC 3:A,B
#1:C,D causes A and B to be printed in record >150 PRINT #1:C,D
3 of the file that was opened as number 1 and
C and D to be printed in record 4 of the same
file.
Program
The program at the right prints out various >100 CALL CLEAR
values in various positions on the display >110 PRINT 1;2;3;4;5;6;7;8;9
screen. >120 PRINT 1,2,3,4,5,6
>130 PRINT 1:2:3
>140 PRINT
>150 PRINT 1;2;3;
>160 PRINT 4;5;6/4
>RUN
1 2 3 4 5 6 7 8 9
1 2
3 4
5 6
1
2
3
1 2 3 4 5 6 1.5
151
Click here to
Return to Table of Contents
PRINT USING
Format
Description
The PRINT USING statement acts the same as PRINT with the addition of the USING clause,
which specifies the format to be used. String-expression defines the format in the manner
described in IMAGE. Line-number refers to the line number of an IMAGE statement. See the
IMAGE statement for more information on the use of string-expression.
Examples
152
Click here to
Return to Table of Contents
RANDOMIZE
Format
RANDOMIZE [numeric-expression]
Description
Program
153
Click here to
Return to Table of Contents
READ
Format
READ variable-list
Description
The READ statement allows you to assign numeric and string constants from a DATA
statement to the variables in variable-list. Variable-list consists of string and numeric
variables, separated by commas.
Data is normally read starting at the first DATA statement in a program. After data is read,
the computer marks where it left off and continues at that point when the next READ
statement is executed. You may change the order in which data is read by using the
RESTORE statement.
154
Click here to
Return to Table of Contents
REC
Format
REC (file-number)
Description
The REC function returns the number of the record that will next be accessed with a PRINT,
INPUT, or LINPUT statement in the file opened as file-number. The record in a file are
numbered starting with 0, so record number 3, for instance, is the fourth record in a file.
Example
PRINT REC(4) prints the current record >100 PRINT REC (4)
position of the file that was opened as
number 4.
Program
Lines 120 through 140 write four records >120 FOR A=0 TO 3
on the file. >130 PRINT #1: "THIS IS RECORD",A
>140 NEXT A
155
Click here to
Return to Table of Contents
REM
Format
REM character-string
Description
The REM statement allows you to enter remarks into your program. The remarks may be
anything that you wish, but are usually used to divide sections of programs and to explain
what the following section is meant to do. No matter what follows REM, including the
statement separator symbol (::), remarks are not executed and have no effect on program
execution. They do, however, take up space in memory.
Example
156
Click here to
Return to Table of Contents
RESEQUENCE
Format
Description
The RESEQUENCE command changes the line numbers of the program in memory, If no
initial-line is given, the line numbering starts with 100, If no increment is given, an increment
of 10 is used. RESEQUENCE may be abbreviated as RES.
If, because of the initial-line and increment chosen, the program requires lines larger than
32767, the resequencing process is halted and the program is unchanged.
Examples
157
Click here to
Return to Table of Contents
RESTORE
Format
RESTORE [line-number]
RESTORE #file-number [,REC record-number ]
Description
The RESTORE statement can be used either with DATA statements or with files. When used
with DATA statements, RESTORE sets the DATA statement which will be used by the next
READ statement. If no line-number is given, the DATA statement with the lowest numbered
line is used by the next READ statement. If line-number is given, then the DATA statement
with that line number or (if it is not a DATA statement) the next DATA statement following it
is used.
When used with files, the RESTORE statement sets the record that is used by the next PRINT,
INPUT, or LINPUT statement referring to file-number. If no REC clause is given, the next
record is the first record in the file, record number 0. If the REC clause is present, record-
number specifies the next record to be used.
Examples
RESTORE 130 sets the next DATA statement to >100 RESTORE 130
be used to the DATA statement at line 130 or, if
line
130 is not a DATA statement, to the next DATA
statement after line 130.
158
Click here to
Return to Table of Contents
RETURN (with GOSUB)
Format
RETURN
Description
Program
159
Click here to
Return to Table of Contents
RETURN (with ON ERROR)
Format
RETURN [Line-number]
RETURN [NEXT]
Description
RETURN is used with ON ERROR. After an ON ERROR statement has been executed, an error
causes transfer to the line specified in the ON ERROR statement. That line, or one after it,
should be a RETURN statement. If RETURN is given without anything following it, control is
returned to the statement on which the error occurred and the program executes it again. If
RETURN is followed by line-number, control is transferred to the line specified and execution
starts with that line. If RETURN is followed by NEXT, control is transferred to the statement
following the one that caused the error.
Program
The program on the right illustrates the use of >100 CALL CLEAR
RETURN with ON ERROR. Line 120 causes an >110 A=1
error to transfer control to line 170. Line 130 >120 ON ERROR 170
causes an error. Line 140, the next line after >130 X=VAL("D")
the one that causes the error, prints 140. Line >140 PRINT 140
170 checks to see if the error has occurred four >150 STOP
>160 REM ERROR HANDLING
times and transfers control to 220 if it has. Line
>170 IF A>4 THEN 220
180 increments the error counter by one. Line
>180 A=A+1
190 prints 190. Line 200 resets the error >190 PRINT 190
handling to transfer to line 170. Line 210 >200 ON ERROR 170
returns to the line that caused the error and >210 RETURN
executes it again. Line 220, which is executed >220 PRINT 220::RETURN NEXT
only after the error has occurred four times, >RUN
prints 220 and returns to the line following the 190
line that caused the error. 190
190
190
220
140
160
Click here to
Return to Table of Contents
RND
Format
RND
Description
The RND function returns the next pseudo-random number in the current sequence of
pseudo-random numbers. The number returned is greater than or equal to zero and less than
one. The sequence of random numbers returned is the same every time a program is run
unless the RANDOMIZE statement appears in the program.
Examples
COLOR16=lNT(RND*16)+ 1 sets COLOR16 equal to >100 COLOR16=INT(RND*16)+1
some number from 1 through 16.
161
Click here to
Return to Table of Contents
RPT$
Format
Description
Examples
M$=RPT$("ABCD",4) sets M$ equal to >100 M$=RPT$("ABCD",4)
"ABCDABCDABCDABCD".
162
Click here to
Return to Table of Contents
RUN
Format
RUN ["device.program-name"]
RUN [line-number]
Description
The RUN command, which can also be used as a statement, starts program execution. The
program to be run is first loaded into memory from device.program-name if that option is
specified. The program, is then checked for certain errors, such as FOR-NEXT loops that are
missing the NEXT statement, and errors in syntax in statements. The values of all numeric
variables are set to zero and the values of all string variables are set to null (a string of zero
characters). The program is then executed.
Options
Examples
163
Click here to
Return to Table of Contents
Program
The program at the light illustrates the use of >100 CALL CLEAR
the RUN command used as a statement. It >110 PRINT "1 PROGRAM 1."
creates a "menu" and lets the person using the >120 PRINT "2 PROGRAM 2."
program chose what other program he wishes >130 PRINT "3 PROGRAM 3."
to run. The other programs should RUN this >140 PRINT "4 END."
program rather than ending in the usual way, >150 PRINT
>160 INPUT "YOUR CHOICE:":C
so that the menu is given again after they are
>170 IF C=1 THEN RUN
finished.
"DSK1.PRG1"
>180 IF C=2 THEN RUN
"DSK1.PRG2"
>190 IF C=3 THEN RUN
"DSK1.PRG3"
>200 IF C=4 THEN STOP
>210 GOTO 100
164
Click here to
Return to Table of Contents
SAVE
Format
Description
The SAVE command allows you to copy the program in memory to an external device under
the name program-name. By using the OLD command, you can later recall the program into
memory. The method of saving onto a cassette recorder is given in the User's Reference
Guide. The method of saving onto a diskette is given in the Disk Memory System manual.
SAVE clears breakpoints that have been put into a program.
Options
You may optionally specify that the program is to be available for merging with another
program by using the key word MERGE. Only programs saved with the key word MERGE may
be merged with another program.
Examples
165
Click here to
Return to Table of Contents
SAY subprogram
Format
Description
The SAY subprogram causes the computer to speak word-string or the value specified by
direct-string when the Solid State Speech TM Synthesizer (sold separately) is connected. For
a complete description of SAY, see the manual that comes with the Speech Editor Command
Module and Speech Synthesizer (both sold separately).
The value of word-string is any string value listed in Appendix L. If it is given as a literal
value, it must be enclosed in quotation marks. The value of direct-string is a value returned
by SPGET. The value of direct-string may be altered to add suffixes as described in Appendix
M.
Word-strings and direct-strings must be alternated in the CALL SAY subprogram. If you wish
to have two direct-strings or word-strings spoken consecutively, you may put in an extra
comma to indicate the position of the item omitted.
Examples
CALL SAY("HELLO, HOW ARE YOU") causes the >100 CALL SAY("HELLO, HOW ARE
computer to say "Hello, how are you." YOU")
CALL SAY(,A$,,B$) causes the computer to say CALL SAY(,A$,,B$)
the words indicated by A$ and BS, which must
have been returned by SPGET.
Program
166
Click here to
Return to Table of Contents
SCREEN subprogram
Format
CALL SCREEN(color-code)
Description
The SCREEN subprogram changes the color of the screen to the color specified by color-code.
All portions of the screen that do not have characters on them, or have characters or portions
of characters that are color 1 (transparent), are shown as the color specified by color-code.
The standard screen color for TI Extended BASIC is 8, cyan.
Code Color
1 Transparent
2 Black
3 Medium Green
4 Light Green
5 Dark Blue
6 Light Blue
7 Dark Red
8 Cyan
9 Medium Red
10 Light Red
11 Dark Yellow
12 Light Yellow
13 Dark Green
14 Magenta
15 Gray
16 White
Examples
167
Click here to
Return to Table of Contents
SEG$
Format
Description
The SEG$ function returns a substring of a string. The string returned starts at position in
string-expression and extends for length characters. If position is beyond the end of string-
expression, the null string ("") is returned. If length extends beyond the end of string-
expression, only the characters to the end are returned.
Examples
168
Click here to
Return to Table of Contents
SGN
Format
SGN ( numeric-expression )
Description
Examples
IF SGN(X2) = 1 THEN 300 ELSE 400 >100 IF SGN(X2)=1 THEN 300 ELSE 400
transfers control to line 300 if X2 if
positive and to line 400 if X2 is zero
or negative.
ON SGN(X)+2 GOTO 200,300,400 >100 ON SGN(X)+2 GOTO 200,300,400
transfers control to line 200 if X is
negative, line 300 if X is zero, and
line 400 if X is positive.
169
Click here to
Return to Table of Contents
SIN
Format
SIN(radian-expression)
Description
The sine function gives the trigonometric sine of radian-expression. If the angle is in degrees,
multiply the number of degrees by PI/180 to get the equivalent angle in radians.
Program
170
Click here to
Return to Table of Contents
SIZE
Format
SIZE
Description
The SIZE command displays the number of unused bytes of memory left in the computer. If
the Memory Expansion peripheral is attached, the number of bytes available is given as the
amount of stack free and the amount of program space free. A byte is the memory space
required for such things as one character or digit, or one TI Extended BASIC keyword.
If the Memory Expansion is not attached, the space available is the amount of space left after
the space taken up by the program, screen, character pattern definitions, sprite tables, color
tables, string values, and the like is subtracted.
If the Memory Expansion is attached, the space available in the stack is the amount of space
left after the space taken up by string values, information about variables, and the like is
subtracted. Program space is the amount of space left after the space taken up by the
program and the values of numeric variables is subtracted.
Examples
171
Click here to
Return to Table of Contents
SOUND subprogram
Format
Description
The SOUND subprogram tells the computer to produce tones or noise. The values given
control three aspects of the sound: Duration; frequency; and volume.
Duration is from .001 to 4.250 seconds, although it may vary up to 1/60th of a second. The
computer continues performing program statements while a sound is being played. When you
call the SOUND subprogram, the computer waits until the previous sound has been completed
before performing the new CALL SOUND. However, if a negative duration is specified, the
previous sound is stopped and the new one is begun immediately.
Frequency specifies the frequency of the note to be played with a value from 110 to 44733.
(NOTE: This range goes higher than the range of human hearing. People vary in their ability
to hear high notes, but generally the highest is approximately a value of 10000.) The actual
frequency produced by the computer may vary up to 10 percent. Appendix D lists the
frequencies of some common notes.
Frequency Description
-1 Periodic Noise Type 1
-2 Periodic Noise Type 2
-3 Periodic Noise Type 3
-4 Periodic Noise that varies with the frequency of the third tone specified.
-5 White Noise Type 1
-6 White Noise Type 2
-7 White Noise Type 3
-8 White Noise that varies with the frequency of the third tone specified.
172
Click here to
Return to Table of Contents
Examples
Program
173
Click here to
Return to Table of Contents
SPGET subprogram
Format
Description
The SPGET subprogram returns in return-string the speech pattern that corresponds to word-
string, For a complete description of SPGET, see the manual that comes with the Speech
Editor Command Module and Solid State Speech TM Synthesizer (both sold separately).
The value of word-string is any string value listed in Appendix L. If it is given as a literal
value, it must be enclosed in quotation marks. The value of return-string is used with SAY,
and may be altered to add suffixes as described in Appendix M.
Program
174
Click here to
Return to Table of Contents
SPRITE subprogram
Format
CALL SPRITE( #sprite-number, character -value, sprite-color, dot-row, dot column, [,row-
velocity, column-velocity] [,...] )
Description
The SPRITE subprogram creates sprites. Sprites are graphics which have a color and a
location anywhere on the screen. They can be set in motion in any direction at a variety of
speeds, and continue their motion until it is changed by the program or the program stops.
They move more smoothly than the usual character which jumps from one screen position to
another.
Sprite-number is a numeric expression from 1 to 28. If the value is that of a sprite that is
already defined, the old sprite is deleted and replaced by the new sprite. If the old sprite has
a row- or column-velocity, and no new one is specified, the new sprite retains the old
velocities.
Sprites pass over fixed characters on the screen. When two or more sprites are coincident,
the sprite with the lowest sprite number covers the other sprites. While five or more sprites
are on the same screen row, the one(s) with the highest sprite number(s) disappear.
Character-value may be any integer from 32 to 143. See the CHAR subprogram for
information on defining characters. The character-value can be changed by the PATTERN
subprogram. The sprite is defined as the character given and, in the case of double-sized
sprites, the next three characters. See the MAGNIFY subprogram for more information.
Sprite-color may be any numeric expression from 1 to 16. It determines the foreground color
of the sprite. The background color of a sprite is always 1, transparent. See the COLOR and
SCREEN subprograms for more information.
Dot-row and dot-column are numbered consecutively starting with 1 in the upper left hand
comer of the screen. Dot-row can be from 1 to 192 and dot-column can be from 1 to 256.
(Actually dot-row can go up to 256, but the positions from 193 through 256 are off the
bottom of the screen.)
The position of the sprite is the upper left hand corner of the character(s) which define it.
Information about the position of a sprite can be found using the POSITION, COINC, and
DISTANCE subprograms. The location of a sprite can be changed using the LOCATE
subprogram. COLOR changes the color of a sprite. Sprites can be deleted with the DELSPRITE
subprogram.
When a breakpoint occurs or the program stops, sprites cease to exist. They do not reappear
with CONTINUE.
175
Click here to
Return to Table of Contents
Row-velocity and column velocity may optionally be specified when the sprite is created. If
both row- and column-velocity are zero, the sprite is stationary. A positive row-velocity moves
the sprite down and a negative value moves it up. A positive column-velocity moves the sprite
to the right and a negative value moves it to the left. If both row-velocity and column -velocity
are non-zero, the sprite moves at an angle in a direction determined by the actual values.
Row- and column-velocity may be from -128 to 127. A value close to zero is very slow. A
value far from zero is very fast. When a sprite comes to the edge of the screen, it disappears
and reappears in the corresponding position on the other side of the screen. The velocity of a
sprite may be changed using the MOTION subprogram.
Programs
The following three programs show some possible uses of sprites. The third one uses all the
subprograms that can relate to sprites except for COLOR and DISTANCE.
176
Click here to
Return to Table of Contents
The program on the right makes a rather spectacular use of sprites.
The following program uses all the subprograms that can relate to sprites except for COLOR
and DISTANCE. They are CHAR, COINC, DELSPRITE, LOCATE, MAGNIFY, MOTION, PATTERN,
POSITION, and SPRITE.
The program creates two double sized magnified sprites in the shape of a person, walking
along a floor. There is a barrier that one of them passes through and the other jumps
through. The one that jumps through goes a little faster after each jump, so eventually it
catches the other one. When it does, they each become double size unmagnified sprites and
continue walking. When they meet the second time, the one that has been going faster
disappears and the other continues walking.
177
Click here to
Return to Table of Contents
Lines 210 through 240 build the >210 CALL COLOR(13,15,15)
barrier. >220 CALL VCHAR(14,22,128,6)
>230 CALL VCHAR(14,23,128,6)
>240 CALL VCHAR(14,24,128,6)
>250 CALL SPRITE(#1,96,5,113
,129,#2,96,7,113,9)
>260 CALL MAGNIFY(4)
178
Click here to
Return to Table of Contents
Lines 470 through 530 handle the fast sprite >470 REM #1 HIT WALL
jumping through the barrier. Line 480 stops >480 CALL MOTION(#1,0,0)
it. Line 490 finds where it is. >490 CALL
POSITION(#1,YPOS1,XPOS1)
Line 500 puts it at the new location beyond >500 CALL LOCATE(#1,YPOS1,193)
the barrier.
Lines 510 and 520 start it moving again, a >510 XDIR=XDIR+1
little faster. >520 CALL MOTION(#1,0,XDIR)
>530 GOTO 300
Lines 540 through 640 handle the second >540 REM SECOND COINCIDENCE
meeting. >550 FOR DELAY=1 TO 500 :: NEXT
DELAY
Line 560 starts the slow sprite moving, while >560 CALL MOTION(#2,0,4)
line 570 deletes the fast sprite. Lines 580 >570 CALL DELSPRITE(#1)
through 630 make the slow sprite walk 20 >580 FOR STEP1=1 TO 20
steps. >590 CALL PATTERN(#2,100)
>600 FOR DELAY=1 TO 20 :: NEXT
DELAY
>610 CALL PATTERN(#2,96)
>620 FOR DELAY=1 TO 20 :: NEXT
DELAY
>630 NEXT STEP1
>640 CALL CLEAR
179
Click here to
Return to Table of Contents
SQR
Format
SQR(numeric-expression)
Description
The SQR function returns the positive square root of numeric-expression. SQR(X) is
equivalent to X^(1/2). Numeric-expression may not be a negative number.
Examples
PRINT SQR(4) prints 2. >100 PRINT SQR(4)
X = SQR(2.57E5) sets X equal to the square >100 X=SQR(2.57E5)
root of 257,000 which is 506.9516742.
STOP
Format
STOP
Description
The STOP statement stops program execution. It can be used interchangeably with the END
statement except that it may not be placed after subprograms.
Program
The program on the right illustrates the use of >100 CALL CLEAR
the STOP statement. The program adds the >110 TOT=0
numbers from 1 to 100. >120 NUMB=1
>130 TOT=TOT+NUMB
>140 NUMB=NUMB+1
>150 IF NUMB>100 THEN PRINT TOT
::STOP
>160 GOTO 130
180
Click here to
Return to Table of Contents
STR$
Format
STR$( numeric-expression )
Description
The STR$ function returns a string equivalent to numeric-expression. This allows the
functions, statements, and commands that act on strings to be used on the character
representation of numeric-expression. The STR$ function is the inverse of the VAL function.
Examples
NUM$ = STR$(78.6) sets NUM$ equal to >100 NUM$=STR$(78.6)
"78.6"
181
Click here to
Return to Table of Contents
SUB
Format
Description
The SUB statement is the first statement in a subprogram. Subprograms are used when you
wish to separate a group of statements from the main program. You may use subprograms to
perform an operation several times in a program or in several different programs or to use
variables that are specific to the subprogram. The SUB statement may not be in an IF – THEN
- ELSE statement.
When a subprogram is in a program, it must follow the main program. The structure of a
program must be as follows:
182
Click here to
Return to Table of Contents
End of Program
183
Click here to
Return to Table of Contents
Options
All variables used in a subprogram other than those in parameter-list are local to that
subprogram. so you may use the same variable names that are used in the main program or
in other subprograms, and alter their values, without having any effect on other variables.
Likewise, the values of variables in the main program or other subprograms have no effect on
the values of the variables in the subprogram. (However, DATA statements are available to
subprograms.)
Communicating values to and from the main program is done with the optional parameter-
list. The parameters need not have the same names as in the calling statement, but they
must be of the same data type (numeric or string), and in the same order as the items in the
CALL. If simple variables passed to subprograms have their values changed in the
subprogram, the values of the variables in the main program are also changed. An array
element such as A(1) in the parameter list of the calling statement is also changed in value in
the main program when control is returned to the main program.
A value that is given in the calling statement as an expression is passed as a value only and
changes in the value in the subprogram do not change values in the main program. Entire
arrays are passed by reference, so changes in elements in the subprogram also change the
values of the elements of the array in the main program. Arrays are indicated by following the
parameter name with parentheses. If the array has more than one dimension, a comma must
be placed inside the parentheses for each additional dimension.
If you wish, you may pass values only for simple variables by enclosing them in parentheses.
Then the value can be used in the subprogram, but it is not changed in the return to the main
program. For example, CALL SPRG1((A)) passes the value of A to a subprogram that starts
SUB SPRG1(X), and allows that value to be used in X, but does not change the value of A in
the main program if the subprogram changes the value of X.
If a subprogram is called more than once, any local variables used in the subprogram retain
those values from one call to the next.
184
Click here to
Return to Table of Contents
Examples
185
Click here to
Return to Table of Contents
Program
Note that this R is not the same >10040 FOR R=1 TO COUNT
as the R used in lines 100 and >10050 READ TEMP$
110 in the main program. >10060 TEMP$=SEG$(TEMP$,1,25)
>10070 DISPLAY AT(R,1):R;TEMP$
>10080 NEXT R
>10090 DISPLAY AT(R+1,1):"YOUR CHOICE: 1"
>10100 ACCEPT AT(R+1,14)BEEP
VALIDATE(DIGIT)SIZE(-2):CHOICE
>10110 IF CHOICE<1 OR CHOICE>COUNT THEN
10100
>10120 SUBEND
186
Click here to
Return to Table of Contents
SUBEND
Format
SUBEND
Description
The SUBEND statement marks the end of a subprogram. When SUBEND is executed, control
is passed to the statement following the statement that called the subprogram. The SUBEND
statement must always be the last statement in a subprogram. The SUBEND statement may
not be in an IF-THEN-ELSE statement. The only statements that may immediately follow a
SUBEND statement are REM, END, or the SUB statement for the next subprogram.
SUBEXIT
Format
SUBEXIT
Description
The SUBEXIT statement allows leaving a subprogram before the end of the subprogram
(indicated with SUBEND). When it is executed, control is passed to the statement following
the statement that called the subprogram. The SUBEXIT statement need not be present in a
subprogram.
187
Click here to
Return to Table of Contents
TAB
Format
TAB(numeric-expression)
Description
The TAB function specifies the starting position for the next print-item in a PRINT,
PRINT...USING, DISPLAY, or DISPLAY...USING statement. If numeric-expression is greater
than the length of a record for the device on which the printing is being done (for example,
28 for the screen, 32 for the thermal printer, the specified value for a file on a diskette or
cassette), then it is repeatedly reduced by the record length until it is between 1 and the
record length.
If the number of characters already printed on the current record is less than or equal to
numeric-expression, the next print item is printed beginning on the position indicated by
numeric-expression. If the number of characters already printed on the current record is
greater than the position indicated by numeric-expression, the next print-item is printed on
the next record beginning in the position indicated by numeric-expression.
The TAB function is treated as a print-item, so it must have a print separator (colon,
semicolon, or comma) before and/or after it. The print separator before TAB is evaluated
before the TAB function. Normally semicolons are used before and after TAB.
Examples
PRINT TAB(12);35 prints the number >100 PRINT TAB(12);35
35 at the twelfth position.
188
Click here to
Return to Table of Contents
TAN
Format
TAN(radian-expression )
Description
The tangent function gives the trigonometric tangent of radian-expression. If the angle is in
degrees, multiply the number of degrees by PI/180 to get the equivalent angle in radians.
Program
TRACE
Format
TRACE
Description
The TRACE command causes each line number to be displayed on the screen before the
statements on that line are executed. This enables you to follow the course of a program as a
debugging aid. The TRACE command may be used as a statement. The effect of the TRACE
command is cancelled when the NEW command or UNTRACE command or statement is
performed.
Example
189
Click here to
Return to Table of Contents
UNBREAK
Format
UNBREAK [line-list]
Description
The UNBREAK command removes all breakpoints. It can optionally be set for only those in
line-list. UNBREAK can be used as a statement.
Examples
UNTRACE
Format
UNTRACE
Description
The UNTRACE command removes the effect of the TRACE command. UNTRACE can be used
as a statement.
Example
190
Click here to
Return to Table of Contents
VAL
Format
VAL(string-expression)
Description
The VAL function returns the number equivalent to string-expression. This allows the
functions, statements, and commands that act on numbers to be used on string-expression.
The VAL function is the inverse of the STR$ function.
Examples
VCHAR subprogram
Format
Description
The VCHAR subprogram places a character anywhere on the display screen and optionally
repeats it vertically. The character with the ASCII value of character-code is placed in the
position described by row and column and is repeated vertically repetition times.
A value of 1 for row indicates the top of the screen. A value of 24 is the bottom of the screen.
A value of 1 for column indicates the left side of the screen. A value of 32 is the right side of
the screen. The screen can be thought of as a grid as shown below.
191
Click here to
Return to Table of Contents
Rows from top to bottom: 1 – 24
Columns from left to right: 1 – 32
Examples
192
Click here to
Return to Table of Contents
VERSION subprogram
Format
CALL VERSION(numeric-variable)
Description
The VERSION subprogram returns a value indicating the version of BASIC that is being used.
TI Extended BASIC returns a value of 100.
Example
193
Click here to
Return to Table of Contents
Appendices
The following appendices give useful information concerning TI Extended BASIC
194
Click here to
Return to Table of Contents
Appendix A - List of Illustrative Programs
Element Illustrated Lines Description Page
44 Codebreaker Game 27
ACCEPT 16 Entry of 20 Names 48
CALL 8 CLEAR and user written subprogram 55
CHAR 12 1. Moving Figure 58
7 2. Resetting characters 58
CHR$ 4 List of ASCII codes 60
CLEAR 3 (Simple Example) 61
3 (Simple Example) 61
COINC 10 (Simple Example) 65
COS 6 (Simple Example) 69
DATA 14 (Simple Example) 71
DELETE 2 (Simple Example) 74
DISPLAY 18 Draw on Screen 78
ERR 5 (Simple Example) 84
FOR-TO-STEP 11 Design 87
GOSUB 24 Probability 90
GOTO 8 Add 1 through 100 91
IF-THEN-ELSE 17 Sequence numbers 96
IMAGE 12 (Simple Example) 99
2 (Simple Example) 99
INPUT 17 Writes Letter 100
INPUT (with files) 12 (Simple Example) 103
JOYST 5 Moves Sprite 108
KEY 12 Moves Sprite 109
LINPUT 6 (Simple Example) 113
LOCATE 6 (Simple Example) 116
LOG 8 Log to any base 117
195
Click here to
Return to Table of Contents
Element Illustrated Lines Description Page
MAGNIFY 17 (Simple Example) 120
MERGE 13 Moves sprite 122
MOTION 8 Moves sprite 125
NEXT 6 (Simple Example) 127
NUMBER 4 (Simple Example) 128
ON BREAK 11 (Simple Example) 130
ON ERROR 15 (Simple Example) 132
ON...GOSUB 20 Choose with a Menu 134
ON...GOTO 19 Choose with a Menu 136
ON WARNING 8 (Simple Example) 137
PATTERN 18 Rolling Wheel 142
POS 8 Break-up Sentence 145
PRINT 7 (Simple Example) 149
RANDOMIZE 5 (Simple Example) 151
REC 12 (Simple Example) 153
RETURN (w. GOSUB) 18 Figure Interest 157
RETURN (w. ON 13 Handle Error 158
ERROR)
RUN 12 Choose with a Menu 162
SAY 4 (Simple Example) 164
SIN 6 (Simple Example) 168
SOUND 4 Play first 13 Notes 171
SPGET 4 (Simple Example) 172
SPRITE 8 (Simple Example) 174
8 Creation of Stars 175
55 Walking sprites 175
STOP 7 Add 1 through 100 178
SUB 21 Choose with a Menu 183
TAN 6 (Simple Example) 186
196
Click here to
Return to Table of Contents
Appendix B - Commands, Statements,
and Functions
The following is a list of all TI Extended BASIC commands, statements, and functions.
Commands are listed first; if a command can also be used as a statement, the letter "S" is
listed to the right of the command. Commands that can be abbreviated have the acceptable
abbreviations underlined. Next is a list of all TI Extended BASIC statements; those that can
also be used as commands have a "C" after them. Finally, there is a list of TI Extended BASIC
functions.
197
Click here to
Return to Table of Contents
TI Extended BASIC functions
198
Click here to
Return to Table of Contents
Appendix C – ASCII Codes
The following predefined characters may be printed or displayed on the screen.
199
Click here to
Return to Table of Contents
Appendix D – Musical Tone Frequencies
The following table gives the frequencies (rounded to integers) of four octaves of the
tempered scale (one half step between notes). While this list does not represent the entire
range of tones that the computer can produce, it can be helpful for programming music.
200
Click here to
Return to Table of Contents
Character Sets – Appendix E
Set ASCII codes Set ASCII codes
0 30-31
1 32-39 8 88-95
2 40-47 9 96-103
3 48-55 10 104-111
4 56-63 11 112-119
5 64-71 12 120-127
6 72-79 13 128-135
7 80-87 14 136-143
201
Click here to
Return to Table of Contents
Color Codes – Appendix G
Color Code Color Code
Transparent 1 Medium Red 9
Black 2 Light Red 10
Medium Green 3 Dark Yellow 11
Light Green 4 Light Yellow 12
Dark Blue 5 Dark Green 13
Light Blue 6 Magenta 14
Dark Red 7 Gray 15
Cyan 8 White 16
202
Click here to
Return to Table of Contents
Color Combinations – Appendix H
The following color combinations produce the sharpest, clearest character resolution.
Best
Second Best
Third Best
Fourth Best
203
Click here to
Return to Table of Contents
Split Console Keyboard – Appendix I
* Note that the first key listed is on the left side of the keyboard and the second key listed is
on the right side of the keyboard.
204
Click here to
Return to Table of Contents
Mathematical Functions – Appendix K
The following mathematical functions may be defined with DEF as shown.
205
Click here to
Return to Table of Contents
List of Speech Words – Appendix L
The following is a list of all the letters, numbers, words and phrases that can be accessed
with CALL SAY and CALL SPGET. See Appendix M for instructions on adding suffixes to
anything on this list.
206
Click here to
Return to Table of Contents
- (NEGATIVE) CENTER F
+ (POSITIVE) CHECK FIFTEEN
. (POINT) CHOICE FIFTY
0 CLEAR FIGURE
1 COLOR FIND
2 COME FINE
3 COMES FINISH
4 COMMA FINISHED
5 COMMAND FIRST
6 COMPLETE FIT
7 COMPLETED FIVE
8 COMPUTER FOR
9 CONNECTED FORTY
A CONSOLE FOUR
A1 CORRECT FOURTEEN
ABOUT COURSE FOURTH
AFTER CYAN FROM
AGAIN D FRONT
ALL DATA G
AM DECIDE GAMES
AN DEVICE GET
AND DID GETTING
ANSWER DIFFERENT GIVE
ANY DISKETTE GIVES
ARE DO GO
AS DOES GOES
ASSUME DOING GOING
AT DONE GOOD
B DOUBLE GOOD WORK
BACK DOWN GOODBYE
BASE DRAW GOT
BE DRAWING GRAY
BETWEEN E GREEN
BLACK EACH GUESS
BLUE EIGHT H
BOTH EIGHTY HAD
BOTTOM ELEVEN HAND
BUT ELSE HANDHELD UNIT
BUY END HAS
BY ENDS HAVE
BYE ENTER HEAD
C ERROR HEAR
CAN EXACTLY HELLO
CASSETTE EYE HELP
208
Click here to
Return to Table of Contents
SPACE TWENTY Z
SPACES TWO ZERO
SPELL TYPE
SQUARE U
START UHOH
STEP UNDER
STOP UNDERSTAND
SUM UNTIL
SUPPOSED UP
SUPPOSED TO UPPER
SURE USE
T V
TAKE VARY
TEEN VERY
TELL W
TEN WAIT
TEXAS INSTRUMENTS WANT
THAN WANTS
THAT WAY
THAT IS INCORRECT WE
THAT IS RIGHT WEIGH
THE (the) WEIGHT
THE1 WELL
THEIR WERE
THEN WHAT
THERE WHAT WAS THAT
THESE WHEN
THEY WHERE
THING WHICH
THINGS WHITE
THINK WHO
THIRD WHY
THIRTEEN WILL
THIRTY WITH
THIS WON
THREE WORD
THREW WORDS
THROUGH WORK
TIME WORKING
TO WRITE
TOGETHER X
TONE Y
TOO YELLOW
TOP YES
TRY YET
TRY AGAIN YOU
TURN YOU WIN
TWELVE YOUR
209
Click here to
Return to Table of Contents
Adding Suffixes to Speech Words –
Appendix M
This appendix describes how to add ING, S, and ED to any word available in the Solid State
Speech TM Synthesizer resident vocabulary.
The code for a word is first read using SPGET. The code consists of a number of characters,
one of which tells the speech unit the length of the word. Then, by means of the
subprograms listed here, additional codes can be added to give the sound of a suffix.
Words often have trailing-off data that make the word sound more natural but prevent the
easy addition of suf fixes. In order to add suffixes this trailing off data must be removed.
The following program allows you to input a word and, by trying different truncation values,
make the suffix sound like a natural part of the word. The subprograms DEFING (lines 1000
through 1130), DEFS1 (lines 2000 through 2100), DEFS2 (lines 3000 through 3090), DEFS3
(lines 4000 through 4120), DEFED1 (lines 5000 through 5070), DEFED2 (lines 6000 through
6110), DEFED3 (lines 7000 through 7130), and MENU (lines 10000 through 10120) should be
input separately and saved with the MERGE option. (The subprogram MENU is the same one
used in the illustrative program with SUB.) You may wish to use different line numbers. Each
of these subprograms (except MENU) defines a suffix.
DEFING defines the ING sound. DEFS 1 defines the S sound as it occurs at the end of "cats. "
DEFS2 defines the S sound as it occurs at the end of "cads. " DEFS3 defines the S sound as it
occurs at the end of "wishes. " DEFED1 defines the ED sound as it occurs at the end of
'.passed..' DEFED2 defines the ED sound as it occurs at the end of "caused. " DEFED3 defines
the ED sound as it occurs at the end of "heated".
In running the program, enter a 0 for the truncation value in order to leave the truncation
sequence.
210
Click here to
Return to Table of Contents
230 PRINT "FIND THE PROPER TRUNCATION"
240 PRINT "VALUE FOR ADDING SUFFIXES"
250 PRINT "TO SPEECH WORDS.": :
260 FOR DELAY=1 TO 300::NEXT DELAY
270 PRINT "CHOOSE WHICH SUFFIX YOU"
280 PRINT "WISH TO ADD. ": :
290 FOR DELAY=1 TO 200::NEXT DELAY
300 CALL MENU(8,CHOICE)
310 DATA 'ING','S' AS IN CATS,'S' AS IN CADS,'S' AS IN WISHES, 'ED'
AS IN PASSED, 'ED' AS IN CAUSED, 'ED' AS IN HEATED,END
320 IF CHOICE=0 OR CHOICE=8 THEN STOP
330 INPUT "WHAT IS THE WORD? ":WORD$
340 ON CHOICE GOTO 350,370,390,410,430,450,470
350 CALL DEFING(D$)
360 GOTO 480
370 CALL DEFS1(D$)!CATS
380 GOTO 480
390 CALL DEFS2(D$)!CADS
400 GOTO 480
410 CALL DEFS3(D$)!WISHES
420 GOTO 480
430 CALL DEFED1(D$)!PASSED
440 GOTO 480
450 CALL DEFED2(D$)!CAUSED
460 GOTO 480
470 CALL DEFED)(D$)!HEATED
480 REM TRY VALUES
490 CALL CLEAR
500 INPUT "TRUNCATE HOW MANY BYTES?" :L
510 IF L=0 THEN 300
520 CALL SPGET(WORD$,B$)
530 L=LEN(B$)-L-3
540 C$=SEG$(B$,1,2)&CHR$(L)&SEG$(B$,4,L)
550 CALL SAY(,C$&D$)
560 GOTO 500
211
Click here to
Return to Table of Contents
The data has been given in short DATA statements to make it as easy as possible to input. It
may be consolidated to make the program shorter.
212
Click here to
Return to Table of Contents
4000 SUB DEFS3(A$)!WISHES
4010 DATA 96,0,34
4020 DATA 173,233,33,84,12
4030 DATA 242,205,166,55,173
4040 DATA 93,222,68,197,188
4050 DATA 134,238,123,102
4060 DATA 163,86,27,59,1,124
4070 DATA 103,46,1,2,124,45
4080 DATA 138,129,7
4090 RESTORE 4010
4100 A$=""
4110 FOR I=1 To 37::READ A::A$=A$&CHR$(A)::NEXT I
4120 SUBEND
213
Click here to
Return to Table of Contents
7000 SUB DEFED3(A$)!HEATED
7010 DATA 96,0,36
7020 DATA 173,233,33,84,12
7030 DATA 242,205,166,183
7040 DATA 172,163,214,59,35
7050 DATA 109,170,174,68,21
7060 DATA 22,201,92,250,24
7070 DATA 69,148,162,38,235
7080 DATA 75,84,97,145,204
7090 DATA 178,127
7100 RESTORE 7010
7110 A$=""
7120 FOR I=1 TO 39::READ A::A$=A$&CHR$(A)::NEXT I
7130 SUBEND
214
Click here to
Return to Table of Contents
You can use the subprograms in any program once you have determined the number of bytes
to truncate. The following program uses the subprogram DEFING in lines 1000 through 1130
to have the computer say the word DRAWING using DRAW plus the suffix ING. Note that it
was found that DRAW should be truncated by 41 characters to produce the most natural
sounding DRAWING. The subprogram DEFING in lines 1000 through 1130 is the program you
saved with the merge option.
215
Click here to
Return to Table of Contents
ERRORS – Appendix N
The following lists all the error messages that TI Extended BASIC gives. The first list is
alphabetical by the message that is given, and the second list is numeric by the number of
the error that is returned by CALL ERR. If the error occurs in the execution of a program, the
error message is often followed by IN line-number
Sorted by Message
216
Click here to
Return to Table of Contents
breakpoint.
69 COMMAND ILLEGAL IN • BYE, CON, LIST, MERGE, NEW, NUM,
PROGRAM OLD, RES, or SAVE used in a program.
217
Click here to
Return to Table of Contents
84 DATA ERROR • READ or RESTORE with data not
present or with a string where a
numeric value is expected.
• Line number after RESTORE is higher
than the highest line number in the
program.
• Error in object file in LOAD.
109 FILE ERROR • Wrong type of data read with a READ
statement.
• Attempt to use CLOSE, EOF, INPUT,
OPEN, PRINT, PRINT USING, REC, or
RESTORE with a file that does not exist
or does not have the proper attributes.
• Not enough memory to use a file.
44 FOR-NEXT NESTING • The FOR and NEXT statement of LOOPS
do not align properly
• Missing NEXT statement.
130 I/O ERROR • An error was detected in trying to
execute CLOSE, DELETE, LOAD, MERGE,
OLD, OPEN, RUN, or SAVE.
• Not enough memory to list a program
16 ILLEGAL AFTER • Anything but END, REM, or SUB after a
SUBPROGRAM SUBEND.
36 IMAGE ERROR • An error was detected in the use of
DISPLAY USING, IMAGE or PRINT
USING.
• More than 10(E-Format) or 14 (numeric
format) significant digits in the format
string.
• IMAGE string is longer than 254
characters.
28 IMPROPERLY USED NAME • An illegal variable name was used in
CALL, DEF, or DIM
• Using a TI Extended BASIC keyword in
LET.
• Using a subscripted variable or a string
variable in a FOR.
• Using an array with the wrong number
of dimensions.
• Using a variable name differently than
originally assigned. A variable can be
only an array, a numeric or string
variable, or a user defined function
name.
• Dimensioning an array twice
• Putting a user defined function name on
the left of the equals sign in an
assignment function.
• Using the same variable twice in the
parameter list of a SUB statement.
218
Click here to
Return to Table of Contents
81 INCORRECT ARGUMENT • CALL and SUB mismatch of arguments
LIST
83 INPUT ERROR • An error was detected in an INPUT
60 LINE NOT FOUND • Incorrect line number found in BREAK,
GOSUB, GOTO, ON ERROR, RUN or
UNBREAK, or after THEN or ELSE.
• Line to be edited not found.
62 LINE TOO LONG • Line too long to be entered into a
program
39 MEMORY FULL • Program too large to execute one of the
following: DEF, DELETE, DIM, GOSUB,
LET, LOAD, ON...GOSUB, OPEN or SUB.
• Program too large to add a new line,
insert a line, replace a line, or evaluate
an expression.
49 MISSING SUBEND • SUBEND missing in a subprogram
47 MUST BE IN SUBPROGRAM • SUBEND or SUBEXIT not in a
subprogram
19 NAME TOO LONG • More than 15 characters in variable or
subprogram name.
43 NEXT WITHOUT FOR • FOR statement missing, NEXT before
FOR, incorrect FOR – NEXT nesting, or
branching into a FOR-NEXT loop.
78 NO PROGRAM PRESENT • No program present when issuing a
LIST, RESEQUENCE, RESTORE, RUN, or
SAVE command.
10 NUMERIC OVERFLOW • A number too large or too small
resulting from a *, +, - , / operation or
in ACCEPT, ATN, COS, EXP, INPUT, INT,
LOG, SIN, SQR, TAN or VAL.
• A number outside the range -32768 to
32767 in PEEK or LOAD.
70 ONLY LEGAL IN A PROGRAM • One of the following statements was
used as a command: DEF, GOSUB,
GOTO, IF, IMAGE, INPUT, ON BREAK,
ON ERROR, ON...GOSUB, ON...GOTO,
ON WARNING, OPTION BASE, RETURN,
SUB, SUBEND, or SUBEXIT.
219
Click here to
Return to Table of Contents
25 OPTION BASE ERROR • OPTION BASE executed more than
once, or with a value other than 1 or
zero.
97 PROTECTION VIOLATION • Attempt to save, list or edit a protected
program.
48 RECURSIVE SUBPROGRAM • Subprogram calls itself, directly or
CALL indirectly.
51 RETURN WITHOUT GOSUB • RETURN without a GOSUB or an error
handled by the previous execution of an
ON ERROR statement.
56 SPEECH STRING TOO LONG • Speech string returned by SPGET is
longer than 255 characters.
40 STACK OVERFLOW • Too many sets of parentheses
• Not enough memory to evaluate an
expression or assign a value.
54 STRING TRUNCATED • A string created by RPT$, concatenation
("&" operator) or a user defined
function is longer than 255 characters.
• The length of a string expression in the
VALIDATE clause is greater than 254
characters.
24 STRING-NUMBER • A string was given where a number was
MISMATCH expected or vice versa in a TI Extended
BASIC supplied function or subprogram.
• Assigning a string value to a numeric
value or vice versa.
• Attempting to concatenate ("&"
operator) a number.
• Using a string as subscript.
135 SUBPROGRAM NOT FOUND • A subprogram called does not exist or
an assembly language subprogram
named in LINK has not been loaded.
220
Click here to
Return to Table of Contents
14 SYNTAX ERROR • An error such as a missing or extra
comma or parenthesis, parameters in
the wrong order, missing parameters,
missing keyword, misspelled keyword,
keyword in the wrong order, or the like
was detected in a TI Extended BASIC
command, statement, function or
subprogram.
• DATA or IMAGE not first and only
statement on a line.
• Items after final ")"
• Missing "#" in SPRITE
• Missing ENTER, tail comment symbol
(!), or statement separator symbol (::).
• Missing THEN after IF.
• Missing TO after FOR.
• Nothing after CALL, SUB, FOR, THEN or
ELSE.
• Two E’s in a numeric constant.
• Wrong parameter list in a TI Extended
BASIC supplied subprogram.
• Going into or out of a subprogram with
GOTO, GOSUB, ON ERROR, etc.
• Calling INIT without the Memory
Expansion Peripheral attached.
• Calling LINK or LOAD without first
calling INIT.
• Using a constant where a variable is
required.
• More than seven dimensions in an
array.
17 UNMATCHED QUOTES • Odd number of quotes in an input line.
20 UNRECOGNIZED • An unrecognized character such as ? or
CHARACTER % is not in a quoted string.
• A bad field in an object file accessed by
load.
221
Click here to
Return to Table of Contents
Sorted by #
10 NUMERIC OVERFLOW
14 SYNTAX ERROR
16 ILLEGAL AFTER SUBPROGRAM
17 UNMATCHED QUOTES
19 NAME TOO LONG
20 UNRECOGNIZED CHARACTER
24 STRING-NUMBER MISMATCH
25 OPTION BASE ERROR
28 IMPROPERLY USED NAME
36 IMAGE ERROR
39 MEMORY FULL
40 STACK OVERFLOW
43 NEXT WITHOUT FOR
44 FOR-NEXT NESTING
47 MUST BE IN SUBPROGRAM
48 RECURSIVE SUBPROGRAM CALL
49 MISSING SUBEND
51 RETURN WITHOUT GOSUB
54 STRING TRUNCATED
56 SPEECH STRING TOO LONG
57 BAD SUBSCRIPT
60 LINE NOT FOUND
61 BAD LINE NUMBER
62 LINE TOO LONG
67 CAN’T CONTINUE
69 COMMAND ILLEGAL IN PROGRAM
70 ONLY LEGAL IN A PROGRAM
74 BAD ARGUMENT
78 NO PROGRAM PRESENT
79 BAD VALUE
81 INCORRECT ARGUMENT LIST
83 INPUT ERROR
84 DATA ERROR
97 PROTECTION VIOLATION
109 FILE ERROR
130 I/O ERROR
135 SUBPROGRAM NOT FOUND
222
Click here to
Return to Table of Contents