TI-Basic Z80 Programming/Introduction
The purpose of this book is to teach both basic and advanced aspects of the TI-BASIC programming language. The book is designed to instruct newcomers with no previous TI-Basic programming experience. Those who have some experience in programming can use the table of contents and appendices to inform themselves on certain aspects of the language, like optimizing code or learning the small yet important differences between certain loop types. Hopefully, the Wikibooks community can contribute a vast amount of useful TI-Basic programming knowledge, which will allow this book to provide a much more in-depth look at TI-Basic. Currently, it only provides information regarding TI-BASIC programming on the TI-83+ or 84+. Of course, the Silver Editions of the two calculators can be used with this guide (the only difference between the TI calculators and their Silver Editions is an increase in available memory).
To learn the language and programming skills from beginning to end, start with this page, the Introduction, and use the links at the bottom of each page to move on to the next chapter.
TI-Basic is a simple programming language used on Texas Instruments (TI) graphing calculators that integrates many normal graphing calculator commands, like storing variables or drawing.
TI-Basic is a relatively easy language to learn, especially when it is compared with Assembly, the other main language used to program TI graphing calculators. Programs written in TI-Basic, compared to programs written in Assembly, have a small file size (due to that fact that commands like
Menu use just 1-2 bytes of memory). However, this makes execution of TI-Basic programs very slow, because the calculator first reads through and parses each line of code before translating it into assembly and executing it. In other words, it suffers from the same performance issues as any interpreted language. Despite its sluggishness, TI-Basic is appropriate for making many simple programs.
A number of conventions are used in this book. Learning these conventions will aid in the learning process.
As this is a book designed to teach one how to program TI-Basic programs, there will be several pieces of code throughout the chapter. Thus, special boxes have been designed so that one can easily find where certain portions of code exist.
There are three main code boxes: Syntax, Examples, and Output.
The commands in TI-Basic must be typed in a particular format. The way a command must be stated is called the syntax. For example, the output function has certain restrictions. There must be a Y coordinate first, then an X coordinate, and then the output. This book explains syntax using boxes like this one:
- Where Row is a number or real variable that will determine the vertical position of Content
- Row can be a number between 1 and 8 (there are 8 lines of text on the screen)
- Where Col is a number or real variable that will determine the horizontal position of Content.
- Col can be a number between 1 and 16 (there are 16 characters across the screen)
- Where Content is a string, number, equation, or variable of any type, that is to be displayed at the specified location.
No surprises here. TI-BASIC uses the same notation for functions as do many programming languages.
Examples are just that. They are examples of commands in use, sometimes only containing one command, sometimes containing more. Often, there is more than one example for a given function, with different variations in the way the command can be used. Examples are formatted as follows:
:15→X :If X=15 :Display "HELLO WORLD"
The previous example will always display HELLO WORLD because X will always be equal to 15.
Usually, but not always, there will be an explanation either before or after the example.
The output is merely used to show how certain programs or functions would look on the calculator. If there is an example prior to the Output box, it is implied that the program was executed from the home screen, but that the program name is not present (i.e. there is no pgrmPROGRAM display for each output). Outputs are displayed as follows:
The normal modes of entry can only use uppercase letters.
Calculator vs Computer
A calculator's screen has the width and pixels to show 16 characters in a row. This constraint is ignored in examples. While the code would be like this on the calculator:
:Disp "Hello, Wo rld!","My name i s Bob"
It is still written this way in examples:
:Disp "Hello, World!","My name is Bob"
In order to enter a command, like Disp, don't individually enter in the letters D i s p, but instead select the command from the program menu by pressing the PGRM key.
The Disp instruction can be found by pressing PRGM (while in the program editor) and using the horizontal arrow keys to scroll over to the I/O menu. Then, press either 3 to immediately paste the command to the editor or use the vertical arrow keys to select the Disp command, then press enter.
To be concise, we write PRGM:I/O:3 for the above. The instructions for accessing the command are included, separated by colons. If a command is accessed by pressing the second key, the menu name is listed first, followed by the button's normal function in parenthesis. If a command uses a menu name, it is stylized in italics.
So, to show Pxl-off(, we write 2ND:DRAW(PRGM):POINTS:5. Press 2ND, PGRM (this will open the DRAW screen since 2nd was pressed), then navigate to POINTS, then press 5 or find the function Pxl-Off(, in the list.
Most instructions can be accessed through the Catalog, 2ND:CATALOG(0), although this method is usually slower. To navigate the catalog quickly, you can jump to a specific starting letter by pushing the key with the related alpha letter.