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 (TI 99/4A)
(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!
== Elements of TI BASIC == ===Editing and running=== Unlike most BASICs of the era, TI BASIC did not provide a [[Full-screen writing program|full-screen editor]]. Instead, a [[line editor]] was provided, which allowed the user to add or edit one line at a time. Explicit line numbers were used to order each statement. It used a {{code|>}} prompt to indicate the current new line in [[direct mode|immediate mode]], as opposed to the more common {{code|READY}}.{{sfn|Guide1981|p=II-5}} Line numbers ranged from 1 to 32767, inclusive, and entering a line outside that range resulted in the "BAD LINE NUMBER" error.{{sfn|Guide1981|p=II-8}} Line entry was aided by the {{code|NUMBER}} command, available only in immediate mode, which entered ascending line numbers,{{sfn|Guide1981|p=II-26}} and {{code|RESEQUENCE}}, which renumbered an existing program.{{sfn|Guide1981|p=II-27}} TI BASIC also included a number of [[debugging]] commands. {{code|BREAK}} worked something like {{code|STOP}}, stopping execution on certain lines. Unlike {{code|STOP}}, the exit to immediate mode did not occur on the line where {{code|BREAK}} appeared, but on the lines {{code|BREAK}} referred to. For instance, {{code|BREAK 130}} would cause the program to exit to immediate mode whenever it moved to line 130. This could be used, for example, by inserting a single {{code|BREAK}} at the top of the program to control execution, rather than having to insert a {{code|STOP}} in the middle of the code. {{code|UNBREAK}} turned off existing breakpoints.{{sfn|Guide1981|p=II-33}} Additionally, {{code|TRACE}} printed out the line number of the currently executing line in angle-brackets: {{code|<100><110>}} etc, and {{code|UNTRACE}} turned it off.{{sfn|Guide1981|p=II-36}} === Statements === The ANSI-compatible [[Statement (computer science)|statements]] of TI BASIC are <code>{{mono|DATA, DEF, DIM, END, [[For loop|FOR..TO..STEP..NEXT]], [[GOSUB]], [[GOTO]], [[Conditional (programming)|IF..THEN..ELSE]], INPUT, LET, NEXT, ON..GOSUB, ON..GOTO, OPTION BASE, PRINT, [[Random number generation|RANDOMIZE]], READ, [[Comment (computer programming)|REM]], RESTORE, [[Return statement|RETURN]], STOP}}</code>. Most of these operate in the same fashion as their MS counterparts with two additions; {{code|RANDOMIZE}} restarts the [[random number generator]] at a given "seed" value, and {{code|OPTION BASE}} sets the first entry in arrays to either 0 or 1, whereas MS is always zero-based. To this standard set it added [[Subroutine|<code>CALL</code>]], [[File descriptor#Operations on the file descriptor table|<code>CLOSE</code>]], <code>DISPLAY</code> and [[Computer file#Operations|<code>OPEN</code>]].{{sfn|Guide1981|p=i}} In keeping with the Minimal BASIC standard,<ref>{{cite tech report |url=https://www.ecma-international.org/wp-content/uploads/ECMA-55_1st_edition_january_1978.pdf |title=Minimal BASIC |date=January 1978 |publisher=ECMA}}</ref> {{code|IF}} statements could only perform branches, they could not perform arbitrary statements as was common in almost every other BASIC of the era. For instance, code such as: {{sxhl|2=basic| 100 IF X>5 THEN PRINT "IT IS LARGE" }} is not valid in TI BASIC. Instead, this would have to be performed using multiple lines: {{sxhl|2=basic|1= 100 IF X<=5 THEN 300 200 PRINT "IT IS LARGE" }} This can easily lead to [[off-by-one error]]s if the conversion is not careful about changing the sense of the boolean comparison. TI BASIC did, however, support the {{code|ELSE}} clause:{{sfn|Guide1981|p=II-51}} {{sxhl|2=basic| 100 IF X>5 THEN 200 ELSE 300 }} The {{code|PRINT}} statement used colons to separate items on different lines, in addition to the more common comma or semicolon. This precluded its use as a statement separator, a concept that TI BASIC did not have.{{sfn|Guide1981|p=II-65}} This means a line can have only a single statement. Due to the way BASIC interpreters work, {{code|GOTO}}-based loops can be sped up significantly by combining code onto a single line, which reduces the number of lines in the program and the corresponding amount of time needed to find a particular line number. This seemingly minor missing feature may result in much slower code, and adding this feature was part of TI Extended BASIC. Extensions to the Minimal BASIC system were often not represented directly in BASIC, but were instead accessed via the {{code|CALL}} command and a series of named GPL-based subroutines. For instance, {{code|CALL CLEAR}} clears the screen, and {{code|CALL KEY}} returns the keycode of the currently pressed key on the keyboard. The language lacked [[PEEK and POKE|<code>PEEK</code> and <code>POKE</code>]] so there was no official way<ref>[https://forums.atariage.com/topic/162941-assembly-on-the-994a/page/11/?tab=comments#comment-2849894 Exploit by James Abbatiello]</ref> to create new CALLable code within BASIC, to do this one would require the TI Editor/Assembler, the TI Mini Memory cartridge which included a small [[assembly language|assembler]],<ref>{{cite web |url=https://www.ninerpedia.org/wiki/Mini_Memory |title=Mini Memory}}</ref> or by using Extended BASIC. === Functions === Unlike Microsoft BASICs, which used <code>{{mono|LEFT$}}</code>, <code>{{mono|MID$}}</code>, <code>{{mono|RIGHT$}}</code>, and <code>{{mono|INSTR}}</code> for manipulating strings, TI BASIC used the ANSI-compliant <code>{{mono|SEG$}}</code> and <code>{{mono|POS}}</code>. ; {{mono|ABS}} : [[Absolute value]] ; {{mono|ASC}} : [[ASCII]] numeric value of the first character of a [[String (computer science)|string]] ; {{mono|ATN}} : [[Trigonometric function|Arctangent]] ; {{mono|CHR$}} : Convert a number into a [[String (computer science)|string]] with an ASCII character ; {{mono|COS}} : [[Trigonometric function|Cosine]] ; {{mono|EOF}} : Test whether the [[End-of-file|end of a file]] has been reached ; {{mono|EXP}} : [[Exponentiation]] ; {{mono|INT}} : greatest integer less than or equal to the parameter ; {{mono|LEN}} : Length of a [[String (computer science)|string]] ; {{mono|LOG}} : [[Natural logarithm]] ; {{mono|POS}} : First occurrence of a string in another string ; {{mono|RND}} : [[Pseudorandom number generator]] ; {{mono|SEG$}} : Return a substring of a string ; {{mono|SGN}} : [[Sign function]] ; {{mono|SIN}} : [[Trigonometric function|Sine]] ; {{mono|SQR}} : [[Square root]] ; {{mono|STR$}} : Convert a number to a [[String (computer science)|string]] ; {{mono|TAN}} : [[Trigonometric function|Tangent]] ; {{mono|VAL}} : Convert a string to a number === Subprograms === Subprograms are called with <code>CALL</code> statement (e.g. <code>CALL CLEAR</code>). * <code>CHAR</code> Definition of graphical characters * <code>CLEAR</code> Clears the [[Computer monitor|screen]] * <code>COLOR</code> Defines foreground- and background color for 8 characters * <code>GCHAR</code> Reads one character at a specified position from the screen * <code>HCHAR</code> Writes a character to a screen position and repeats it horizontally * <code>JOYST</code> Returns the position of the [[joystick]] * <code>KEY</code> Reads from the keyboard without echo on the screen * <code>SCREEN</code> Changes the color of the screen * <code>SOUND</code> Creates sounds (using a [[frequency]]) and noise * <code>VCHAR</code> Writes a character to a screen position and repeats it vertically
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)