The Basics of BASIC

This section provides basic information for programmers new to TI-BASIC and non- programmers. If you have used TI-BASIC before, you can skip over most of this material.

A. Programs and Functions


If you are new to the 89 and 92, but have programmed TI-BASIC before, the first thing you are likely to notice is the addition of functions. You are probably wondering by now what the differences between programs and functions are. Well, here it is... nothing. Okay, so there are a few differences. Functions can return values on the home screen, but cannot write to folder variables. That's all that really matters. For now, don't worry about it. We will deal mainly with programs in these lessons. All you need to know is that programs and functions execute a series of commands just as if you had typed them one by one into the homescreen.

B. Variables


There are three general types of variables: folder, local, and system. Each of these has a different scope.

Folder variables can be recalled from anywhere, but most easily from the folder they are in. To recall a variable while in it's folder, simply type the name of the variable. If you are not in the same folder as the variable, you must type the directory, followed by a backslash (2nd then 2),then the variable name (ex. Main\A woudl recall the variable named A in the directory Main). You can have more than one variable of the same name as long as they are in different folders.

Local variables exist only in the program (or function) in which they were initialized. (An important exception to this is passing the value of a local variable to another program, but we'll get to that later.) Local variables must be initialized in the start of a program or function:

Demo()
Prgm
Local a,b,c
...
...
...
Endprgm

System variables cannot be found in the var-link menu. They are important values used by the calculator in certain applications. Most are generally useless. You cannot delete most system variables (there are a few exceptions, and these variables will appear in var-link). A complete list can be found on page 537 of your manual. The most commonly used are the graph functions (ex. y1(x)), the graph window variables (ex. xmin), and OK (used with dialogs). Other than these, don't worry about system vars. They will do their job and stay out of your way.

There are a number of different kinds of variables which will be explained in detail in section III. These include expr, list, mat, data, equ, and pic.

C. Giving the user information

The return of information to the user is known as output. Output in TI-BASIC includes the IO screen, the graph screen, and dialog boxes.

Writing to the IO screen is by far the easiest. Either use DISP [expr or string],[expr or string],... or use OUTPUT row,column,expr or sting. DISP will display the expression or string on the IO screen and scroll old information if necessary. DISP with more than one argument, is the same as using DISP on each individually. TIP: Use DISP with multiple arguments instead of multiple times. Output writes the expression of string on the IO screen at the sprcified coordinates (in pixels). To clear the IO screen use CLRIO.

Writing to the graph screen is somewhat more complicated. You can use PXLTEXT string,row,col or PTTEXT string,x,y. TIP: Use PXLTEXT instead of PTTEXT to avoid having to set the window. To clear the graph screen use CLRDRAW (CLRGRAPH clears functions that have been graphed, FNOFF 1,2,... disables a function from graphing).

Dialog boxes have a more complicated format. I will explain this is more detail in sections III and IV.

D. Getting information from the user.


The reception of information from the user is known as input. Input in TI-BASIC includes prompts, input, dialogs, toolbars, and key presses.

To recieve information in the IO screen, use PROMPT var1,var2,... This will display the name of the variable followed by a question mark. The expression typed by the user will be stored in this variable. INPUT [sting],var is the same as prompt except it displays the string instead of the variable name. If the string is omitted, a question mark is displayed. IMPORTANT: PROMPT and INPUT treat what they receive as expressions. Use Inputstr [string],var to recieve a string.

You can recieve graph coordinates by using INPUT with no arguments.

More information on dialogs, toolbars, and key presses can be found in section V.

E. Conditional Statements

We will discuss conditional statements in section VI. For now, simply know that you use a conditional statement to compare values and behave appropriately.

F. Branching

A program branches after a conditional statement. This simply means that it behaves in a different manner depending on the result of a comparison. We will discuss branching in section VII.

G. Loops

Lops are among the programmers most useful tools. There are two kinds of loops that we will deal with. LOOP ... ENDLOOP will execute what is the the middle indefinitely until a branch sends it out of the loop.

A FOR loop is similar to LOOP except it only executes a set number of times. FOR loops can also be left early if a branch sends the execution elsewhere.

This concludes our discussion of the basics. If you don't understand this, you won't understand what follows, so read it again. If you do understand this, you're ready to move on to our first in-depth discussion: Variables.

<<Previous - Contents - Next>>