Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
TI-BASIC
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== 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 [[whitespace character|white space]] or indentation. It is also dependent on a somewhat non-standard [[TI calculator character sets|character set]], with specific characters for assignment (the right "STO" arrow, not readily available in most character sets), [[square root|square]] and [[cube root]]s, and other mathematical symbols, as well as [[tokenize]]d entry and storage for keywords. All statements begin with a colon, which also functions as a statement separator within lines. On the TI-83/84 models, 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, on TI 83/84 models the [[for loop]] function runs much slower without closing parentheses in certain circumstances.<ref>https://tibasicdev.wikidot.com/timings Analysis of different command times.</ref> 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 (programming language)|algol]]-like <code>:=</code> operator, TI-BASIC uses a right-arrow <code>sto''β''</code> 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 [[conditional (programming)|if-then-else blocks]], [[for loop]]s, [[while loop]]s, and [[do while loop|repeat loops]], though no [[switch statement]]s. The main control flow statements are:<ref>{{Cite web |title=Skill Builder 1: Loops and the For(...) loop |url=https://education.ti.com/-/media/ti/files/resources/ti-codes/84/unit-4/skill-builder-1/unit-4-skill-builder-1_teacher.pdf |access-date=April 17, 2025 |website=TI Education}}</ref> <pre> If condition Then ... Else ... End For(variable,start,stop,step) ... End While condition ... End Repeat condition ... End </pre> Unusual for a high level language, TI-BASIC implementations include IS> (Increment and Skip if Greater Than) and DS< (Decrement and Skip if Less Than) statements, constructs generally associated with [[assembly language]]s. Sections of programs can be [[Label (programming language)|labeled]]; however, particularly on the Z80 models, the labels function as destinations for [[Goto]] statements or <code>Menu(</code> 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 [[strong typing|strongly]] and [[dynamic typing|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 [[record (computer science)|structs]]. ==== TI-83/84 (Z80) ==== * Numerical [[variable (programming)|variables]], including <code>A</code> - <code>Z</code> and <code>[[theta|ΞΈ]]</code> (theta). These allow [[real number]]s or [[complex number]]s (implemented as pairs of reals) to be stored in [[floating point]] format. Values may range from 1<small>E</small>-99 to 1<small>E</small>99 with 14 digits of accuracy,<ref>{{Cite book |url=https://education.ti.com/html/eguides/discontinued/computer-software/EN/SDK-TI-83-Developer-Guide_EN.pdf |title=TI-83 Plus Developer Guide |date=May 28, 2002 |publisher=Texas Instruments Incorporated |edition=3rd |pages=22β23 |language=en |archive-date=March 19, 2025 |access-date=August 15, 2024 |archive-url=https://web.archive.org/web/20250319142345/https://education.ti.com/html/eguides/discontinued/computer-software/EN/SDK-TI-83-Developer-Guide_EN.pdf |url-status=live }}</ref> 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. * [[String (computer science)|Strings]], including <code>Str0</code> - <code>Str9</code>. 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 <code>expr()</code> function, which is found in the catalog. * Lists, including <code>L<small>1</small></code> - <code>L<small>6</small></code>, with the ability to create additional ones. These are essentially [[one-dimensional]] [[array data type|arrays]] used to store a real or complex number into each of their [[array data structure|elements]]. The [[dimension]] of a list, its number of elements, may range from 1 to 999, although [[available]] [[Random-access memory|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 <code>dim(</code> of the list name. The default lists are named L<small>1</small>βL<small>6</small>, but custom lists can be created. This is done by setting dimension of a list referenced with the <small>L</small> [[lexical analysis#Token|token]] in the <code>Lists</code>, followed by a name ranging from 1 to 5 [[character (computing)|characters]] that begins with an uppercase letter <code>A</code> - <code>Z</code> and <code>[[theta|ΞΈ]]</code>. Individual elements of lists can be accessed by placing the element number in [[Bracket#Parentheses|parentheses]] after the list name. * [[Matrix (mathematics)|Matrices]], including <code>[A]</code> - <code>[J]</code>. 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 <code>Y<small>0</small></code> - <code>Y<small>9</small></code>, <code>r<small>1</small></code> - <code>r<small>6</small></code>, and <code>u</code>, <code>v</code>, <code>w</code>. 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). (<code>Y<small>1</small></code>(4) would return the value of <code>Y<small>1</small></code> at X=4) Data types that cannot be directly manipulated include: * Pictures (<code>Pic0</code> - <code>Pic9</code>) * Background (<code>Image0</code> - <code>Image9</code>) * Programs (<code>prgm</code>) * Graph databases (<code>GDB0</code> - <code>GDB9</code>) * Color (<code>BLUE</code>, <code>RED</code>,..., <code>GRAY</code>) (15 colors in total) ==== TI-89 (68k) ==== * Integers, which can store a large amount of data. The 68k calculators can store very large numbers, as high as <math>10^{600}</math>, 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. * [[String (computer science)|Strings]] * Lists, which are one-dimensional [[linked list]]s which support element-wise operations. On the 68k calculators, elements can be integers, reals, complex numbers, strings or expressions. * [[Matrix (mathematics)|Matrices]], with elements subject to the same restrictions in lists * [[Symbolic computation|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 series|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 <code>[A]</code>-<code>[J]</code>). On the TI-83/84 certain variables such as <code>Ans</code> and the finance variables have fixed addresses in RAM, making them much faster to access than the 27 letter variables. <code>Ans</code> 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 <code>Ans</code> as a result. Because <code>Ans</code> 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 (68k) ==== In contrast, 68k calculators allow all variable names to have up to eight alphanumeric characters, including [[Greek alphabet|Greek]]. Furthermore, variables can be grouped into "folders", or made [[local variable|local]] to a program by declaring them with the <code>Local</code> 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 <code>Ans</code> variable, but this does not affect anything other than performance unless <code>Ans</code> is read immediately afterwards. ==== TI-89 (68k) ==== The 68k calculators allow programs to include single-line [[comment (computer programming)|comments]], using [[copyright symbol|Β©]] as a comment 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 68k interpreter has a built in feature to store the number of space characters at the beginning of a line, this allows [[Indentation style|indentation]]. === Functions === ==== TI-83/84 (Z80) ==== The Z80 version of TI-BASIC makes explicit "functions" like those in 68k impossible. 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 <code>Return</code> statement stops the current program and continues where the program was called. ==== TI-89 (68k) ==== The 68k version of TI-BASIC allows creating user-defined functions. Functions have the same syntax as programs except that they use the <code>Func</code>...<code>EndFunc</code> keywords instead of <code>Prgm</code>...<code>EndPrgm</code>, 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 function|pure]] because they can call built-in functions such as <code>getTime()</code>, <code>getKey()</code>, or [[pseudorandom number generator|<code>rand()</code>]]. All functions have a return value, which in the absence of an explicit <code>Return</code> statement is the last expression evaluated. === Third-party language extensions === Third-party applications, in chronological order Omnicalc,<ref>ticalc.org. [https://www.ticalc.org/archives/news/articles/6/62/62080.html Omnicalc v1.00 Released] {{Webarchive|url=https://web.archive.org/web/20240614230434/https://ticalc.org/archives/news/articles/6/62/62080.html |date=2024-06-14 }}</ref> xLIB,<ref>Evans, Travis. [https://www.ticalc.org/archives/news/articles/14/146/146528.html xLIB by Patrick Prendergast] {{Webarchive|url=https://web.archive.org/web/20240614230744/https://ticalc.org/archives/news/articles/14/146/146528.html |date=2024-06-14 }}</ref> Celtic, and Doors CS,<ref>Sutherland, Nikky. [https://www.ticalc.org/archives/news/articles/14/146/146642.html Find an Oasis in Doors CS 7.0] {{Webarchive|url=https://web.archive.org/web/20231127142330/https://www.ticalc.org/archives/news/articles/14/146/146642.html |date=2023-11-27 }}</ref> have overloaded TI-BASIC functions on the Z80 calculators to provide additional language functionality. The third-party libraries overload the <code>sum()</code>, <code>real()</code>, <code>det()</code> and <code>identity()</code> functions, which are handled and interpreted by their respective applications. Among the extra functions are fast shape-drawing routines, sprite and tilemap tools, program and VAT modification and access abilities, GUI construction features, and much more, most of which are ordinarily restricted to use by assembly programmers. All of the functions require that an application like [http://www.ticalc.org/archives/files/fileinfo/430/43068.html Doors CS 7.0] be present on the user's calculator, sometimes considered a detraction to the use of the libraries.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)