TI-BASIC is the official name of several BASIC-like programming languages used by Texas Instruments' graphing calculators. It is a language family of three different and partially-incompatible versions, released on different products: TI-BASIC 83 for the Zilog Z80-based TI-83 and TI-84 Plus series TI-BASIC 89 for the Motorola 68000-based TI-89 and TI-92 series TI-BASIC Nspire for the ARM-based TI-Nspire series TI rarely refers to the language by name, but the name TI-BASIC has been used in some developer documentation.https://education.ti.com/educationportal/sites/US/productDetail/us_ti89ti.html?bid=5 TI-89 at education.ti.com
Built into every TI graphing calculator, it is the primary method of programming available to the user. On most calculators, assembly language can also be used, and C cross-compilers exist for translation into assembly: TIGCC for 68000-based calculators, and SDCC for Z80-based calculators; these do not run on the calculator itself.
As an interpreted language, TI-BASIC is considerably slower than assembly, making it better suited to writing programs to quickly solve math problems or perform repetitive tasks, rather than programming games or graphics-intensive applications. TI-BASIC programs (usually written in TI-BASIC 83) can also be found in math textbooks.
Despite its limitations, a growing community of TI-BASIC programmers has developed, mainly on the Internet.
Syntax The syntax of all versions of TI-BASIC are somewhat different from typical BASIC implementations. The language itself has some basic structured programming capabilities, but makes limited to no use of or allowance for white space or indentation. It is also dependent on a somewhat non-standard character set, with specific characters for assignment (the right "STO" arrow, not readily available in most character sets), square and cube roots, and other mathematical symbols, as well as tokenized entry and storage for keywords. All statements begin with a colon, which also functions as a statement separator within lines. In TI-BASIC 83, closing parentheses, brackets, braces, and quotes can optionally be omitted at the end of a line or before the STO token in order to save space, although sometimes they are better left on; for example, the for loop function runs much slower without closing parentheses in certain circumstances.https://tibasicdev.wikidot.com/timings Analysis of different command times.
Expressions use infix notation, with standard operator precedence. Many statements demand arguments in parentheses, similar to the syntax used for mathematical functions. The syntax for assignment (copying of data into a variable) is unusual with respect to most conventional programming languages for computers; rather than using a BASIC-like let statement with an equal sign, or an Algol-like := operator, TI-BASIC uses a right-arrow sto→ operator with the syntax: source → destination. This is similar to several Japanese calculators, such as from Casio, Canon and Sharp, that have often employed a similar syntax, ever since the first mass market Japanese alphanumerical calculators appeared in the late 1970s and early 1980s.
Control flow Control flow statements include if-then-else blocks, for loops, while loops, and repeat loops, though no switch statements. The main control flow statements are: If condition Then ... Else ... End
For(variable,start,stop,step) ... End
While condition ... End
Repeat condition ... End Unusual for a high level language, TI-BASIC implementations include (Increment and Skip if Greater Than) and (Decrement and Skip if Less Than) statements, constructs generally associated with assembly languages. Sections of programs can be labeled; however, particularly on the Z80 models, the labels function as destinations for Goto statements or Menu( functions rather than as program or block labels.
Availability of functions and subroutines depends on the implementation; the versions available on the TI-82-descended calculators do not even support a GOSUB-like function, though it is possible to call programs from within each other and share variables between programs. TI-89/92-based designs can have access to shared functions, essentially programs capable of returning a value.
Data types TI-BASIC is a strongly- and dynamically-typed language. Available data types differ considerably between the 68k and Z80 versions. It is not possible to create user-defined data types without using a library written in assembly. Lists are often used as a replacement for structs.
TI-83/84 (Z80) Numerical variables, including A - Z and θ (theta). These allow real numbers or complex numbers (implemented as pairs of reals) to be stored in floating point format. Values may range from 1E-99 to 1E99 with 14 digits of accuracy, although only 10 digits are usually displayed to users. The limit of 27 variables, however, may be expanded through the use of lists, matrices, and manipulation of integer notation. A list or matrix can be used to contain unique real variables which can be individually referenced. Integers can be concatenated into a single real variable by delineating them as the integer and decimal halves of a real number; each half is then accessed independently via the iPart and fPart commands. Variables with binary values can be stored as a single integer through conversion between base 2 and base 10. Strings, including Str0 - Str9. These may store any number of characters or even function names, as long as there is available memory. They can be evaluated as an expression with the expr() function, which is found in the catalog. Lists, including L1 - L6, with the ability to create additional ones. These are essentially one-dimensional arrays used to store a real or complex number into each of their elements. The dimension of a list, its number of elements, may range from 1 to 999, although available memory may be a limiting factor. When a list's dimension is set lower than it had been, elements at the end are cut off. When set higher, extra elements at the end are filled with zeros. Dimensions are set by storing a valid number into the dim( of the list name. The default lists are named L1–L6, but custom lists can be created. This is done by setting dimension of a list referenced with the L token in the Lists, followed by a name ranging from 1 to 5 characters that begins with an uppercase letter A - Z and θ. Individual elements of lists can be accessed by placing the element number in parentheses after the list name. Matrices, including [A] - [J]. Their elements are subject to the same restrictions as lists. Their dimensions may be defined up to 99x99 elements, although, again, available memory will limit this. It is not possible to create user-defined matrices, so only the ten built in ones may be utilized. Equation variables, including Y0 - Y9, r1 - r6, and u, v, w. These are essentially strings which store equations. They are evaluated to return a value when used in an expression or program. Specific values, (constant, C) can be plugged in for the independent variable (X) by following the equation name (dependent, Y) by the constant value in parentheses. In the example below, "(4)" is used (for no particular reason). (Y1(4) would return the value of Y1 at X=4)
Data types that cannot be directly manipulated include: Pictures (Pic0 - Pic9) Background (Image0 - Image9) Programs (prgm) Graph databases (GDB0 - GDB9) Color (BLUE, RED,..., GRAY) (15 colors in total)
TI-89/92 (68k) Integers, which can store a large amount of data. The 68k calculators can store very large numbers, as high as , with perfect accuracy. Real numbers, using decimal floating point. These store up to 14 significant digits depending on the calculator model. Complex numbers, implemented as pairs of reals. Strings Lists, which are one-dimensional linked lists which support element-wise operations. On the 68k calculators, elements can be integers, reals, complex numbers, strings or expressions. Matrices, with elements subject to the same restrictions in lists Symbolic expressions, unique to the 68k series.
Data types that cannot be directly manipulated (typing only their name on a line would result in an error) include: Pictures Data Programs Functions
Variables Flexibility in the use of variables varies widely by the calculator model. For example, on the TI-84 Plus, all English language letters as well as theta (Θ) are available.
TI-83/84 (Z80) On the TI-83/84, the programmer can create lists whose names are up to five characters. All other data types are limited, such as the 27 real or complex variables, and a number of predefined variable names of other types (e.g., matrices have to be one of the ten variables [A]-[J]). On the TI-83/84 certain variables such as Ans and the finance variables have fixed addresses in RAM, making them much faster to access than the 27 letter variables. Ans acts as a special variable containing the result of the last evaluated code. A line with just a variable will still be evaluated and its contents stored in Ans as a result. Because Ans is reevaluated so frequently it most often is used to store very temporary calculations or to hold values that would otherwise be slow to access such as items from a list. All variables are global.
TI-89/92 (68k) In contrast, 68k calculators allow all variable names to have up to eight alphanumeric characters, including Greek. Furthermore, variables can be grouped into "folders", or made local to a program by declaring them with the Local statement.
Comments TI-83/84 (Z80) Z80 programmers often start lines with " (double quotation mark) to denote a comment. Lines starting with " are actually executed changing the Ans variable, but this does not affect anything other than performance unless Ans is read immediately afterwards.
TI-89/92 (68k) The 68k calculators allow programs to include single-line comments, indicated by a copyright symbol (©). If a comment appears as the first line after the "Prgm" statement, it is displayed in the status bar when the program is selected in the catalog; such comments are often used to document the names or types of parameters. The BASIC interpreter can store the number of space characters at the beginning of a line, allowing indentation.
Functions TI-83/84 (Z80) The Z80 version of TI-BASIC does not support functions; however, all variables are global so functions can be emulated by setting variables, similar to arguments, before calling another program. Return values do not exist; the Return statement stops the current program and continues where the program was called.
TI-89/92 (68k) The 68k version of TI-BASIC allows creating user-defined functions. Functions have the same syntax as programs except that they use the Func...EndFunc keywords instead of Prgm...EndPrgm, and that they are not allowed to use instructions that perform I/O, modify non-local variables, nor call programs. However, functions can still be non-pure because they can call built-in functions such as getTime(), getKey(), or rand(). All functions have a return value, which in the absence of an explicit Return statement is the last expression evaluated.
Third-party language extensions