TI-Basic Z80 Programming/Introduction

PurposeEdit

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.

OverviewEdit

TI-BASIC is a simple programming language used on Texas Instruments (TI) graphing calculators that integrates many normal graphing calculator commands, like calculations and graphing.

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 the fact that commands like If and Menu use just 1 or 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, similar to Python. 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.

ConventionsEdit

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.

SyntaxEdit

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, Output (PRGM I/O 6) has certain restrictions. You must state the row, then the column, then the content in that order to display an output. This book explains syntax using boxes like this one:

Output(row,col,value)
  • 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 value 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.

ExamplesEdit

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:

:Input X            // Store user input to X
:If X=15            // If the value in X is equal to 15
:Disp "HELLO WORLD" // Show "HELLO WORLD" on the screen

Text to the right of a // represents a comment, used for explaining what the code is actually doing, line by line. This is only for display uses here in this Wikibook, and cannot be used in an actual program.

Usually, but not always, there will be an explanation either before or after the example.

OutputEdit

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. Outputs are displayed as follows:

HELLO WORLD

The normal modes of entry can only use uppercase letters.

Calculator vs. ComputerEdit

CodeEdit

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"

CommandsEdit

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 PRGM key.

The Disp instruction can be found by pressing PRGM (while in the program editor) and using the right arrow key to scroll over to the I/O menu. Then, press either 3 to immediately paste the command to the editor or use the down arrow key 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. If a command uses a menu name, it is stylized in italics. If 2ND must be pressed to open a menu, the menu will be bracketed in lieu of the actual key being pressed (e.g., 2ND MATH becomes 2ND [TEST]).

As an example, to access Pxl-Off(, we write 2ND [DRAW] POINTS 5. Press 2ND, PRGM (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], 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.


Next: Necessary Items
Table of Contents: TI-Basic Z80 Programming