my-server
← Wiki

TI-BASIC 83

TI-BASIC 83, TI-BASIC Z80 or simply TI-BASIC, is the built-in programming language for the Texas Instruments programmable calculators in the TI-83 series. Calculators that implement TI-BASIC have a built in editor for writing programs. While the considerably faster Z80 assembly language is supported for the calculators, TI-BASIC's in-calculator editor and more user friendly syntax make it easier to use. TI-BASIC is interpreted.

Syntax

The syntax for TI-BASIC 83 is significantly different compared to most dialects of BASIC. For example, the language does not permit indentation with whitespace characters. It also depends on the TI calculator character set because it is tokenized. Aside from these differences, TI-BASIC retains most control flow statements: conditionals, various loops, GOTOs and Labels. Conditionals and loops use <code>End</code> to denote the end of their bodies.

Each command can be placed on a new line, or separated by a colon for brevity. As such, the following snippets are identical in function. <pre>

Disp 42
Disp "FOOBAR

and

Disp 42:Disp "FOOBAR

</pre>

In the above example the closing double quotes can be omitted because the colon causes all open markers to be closed.

Unlike many high-level programming languages, TI-BASIC has only one assignment operator: <code>→</code>. The rightward arrow (Known as "STO" on most calculators) assigns the value on the left to the variable on the right.

Conditionals

TI-BASIC includes simple constructs using the <code>If</code> statement. When the <code>If</code> token does not have a <code>Then</code> token on the following line it will only execute the next single command.

<pre>

If condition
command

</pre>

Where <code>condition</code> is any boolean statement. One benefit of this format is brevity as it does not include <code>Then</code> and <code>End</code>. An <code>If</code> statement may have more than one command in its body if, instead of a command, a <code>Then</code> token is placed. <pre>

If condition
Then
command
command
End

</pre> When using <code>Then</code>, the body must be closed by an <code>End</code> token. One more construct utilizes <code>Else</code>. This allows one of two bodies to be executed. <pre>

If condition
Then
body one
Else
body two
End

</pre> In this case the calculator evaluates <code>condition</code>, if it evaluates to true <code>body one</code> is executed, however, if <code>condition</code> evaluates to false, <code>body two</code> is executed. Unlike many other programming languages, TI-BASIC has no <code>else if</code> construct, or any switch statement.

Menu( statement

It does, however, have a <code>Menu(</code> statement which allows a user to select one of a number of options. Similar to a switch menus do have fallthrough. The general syntax is <code>Menu(</code>, a quoted title string, and followed by quoted option name and label name. An example: <pre>

Menu("TITLE","FIRST",1,"SECOND",2,"THIRD",3)
Lbl 1
body one
Lbl 2
body two
Lbl 3
body three

</pre>

The image is how the calculator renders the example above.

In terms of functionality, the <code>Menu(</code>'s flow is similar to some switch statement and cases, with a key difference that the user supplies the switch's usual expression. Like many switches and cases, the <code>Lbl</code> allows fall-through. For example, in the code above, if a user selects "FIRST", all three bodies are executed. However, selecting "SECOND" means only the second and third bodies are executed.

Loops

TI-BASIC includes three types of loops: <code>For(</code>, <code>While</code>, and <code>Repeat</code>.

For(

<code>For(</code> is similar to many other languages. It will repeat commands either a set number of times, or a variable number. <pre>

For(variable,start,end[,increment])
body
End

</pre>

While and Repeat

<code>While</code> takes a single argument, a condition which must be fulfilled, without parentheses. <code>Repeat</code> functions the same way except that it loops when the given condition is false. <pre>

While condition
body
End

</pre>

DS<( and IS>(

<code>DS<(</code> and <code>IS>(</code> are specialized conditionals that are similar in overall function to <code>If</code> statements. However, they have the unique property of changing the value of the given variable. <pre>

DS<(variable,value)
Command

</pre>

Data types and variables

TI-BASIC is strongly and mostly statically typed. Most variables, besides lists and programs, have predefined names and allowed types. Each variable can usually only hold one data type, the exceptions are the numeric and all list variables which can hold either real or complex values.

Numeric

There are 27 numeric variables, <code>A</code> through <code>Z</code>, and <code>θ</code>. These can hold two types of values, real and complex. All numbers are stored in the RAM as floating-point numbers with 14-digit mantissa, or significand, and an exponent range of -128 to 127. Complex numbers are stored as two consecutive reals.

List

Lists are also supported through the use of six built-in lists, and user created lists with up to five characters as the name. They are capable of holding up to 999 elements. A list may hold entirely real numbers or entirely imaginary numbers. Some functions in the calculator are able to operate over entire lists, via Array programming.

Matrix

Matrices are supported through the use of ten built-in matrices. Matrices do not support user created names or complex numbers.

Strings

There are ten built-in strings for storing variable text, named <code>Str1</code> through <code>Str9</code> and <code>Str0</code>.

Other data types

The TI-83 family supports several more data types other than numeric, list, and matrix types: token based data, screen image data, and graph database data. These data types cannot be directly manipulated by TI-BASIC.

References

External links