DGSoft Studios
Tutorials

News | Downloads | Who? | Tutorials

Tutorial 1

If you find your BASIC programs a little slow (and who doesn't?) or long, and you consider yourself very good at programming in TI-BASIC, then this tutorial is for you. There are certain techniques and other methods that are often overlooked that can make a big difference in your finished program in both size and also in speed. I will use /->/ as the store key throughout this tutorial.

First, you should start doing this immediately: chop off all trailing parentheses, list brackets, matrix brackets, and quotes, both at the end of a line, and before a /->/ symbol. This means

Output(1,1,"Hello.")
is the same exact thing to the calculator as
Output(1,1,"Hello.
and
{1,2,3,4}/->/L1
is the same as
{1,2,3,4/->/L1
. However, you cannot omit closing brackets, etc. if there are any other symbols except other closing symbols after it.

The colon symbol (:) can be used to denote a new statement, but so can an enter character. Usually, I will use an enter character, because it allows for cleaner code, and you can trim off closing brackets, etc. that way. If you just include a colon, that will not work. However, I like to use the colon to call subroutines if setting values to variables is required, like so:

3/->/A:7/->/B:prgmSUBROUTA
. This is clearer to me, and because it requires the same amount of space, I use it.

Goto statements are PURE EVIL!!! if they are used too abundantly. This is because the TI-OS searches from the top for your label. In big programs, it can take very noticable amounts of time for it to find the labels. Try to keep them to a minimum. In cases where you use the goto statement to call a subroutine, just write a different program for the subroutine, and call it from within the program [PRGM][EXEC] then select your subroutine program from the list. Subroutines also allow your main program to be smaller, therefore you don't have to scroll as much to get to the bottom of the program, or wherever you need to write code from.

Instead of writing Goto/Lbl loops, use For(), While, and Repeat statements. The syntax for the For() statement is

For([variable],[start],[stop],[increment])
. The [] brackets do not refer to matrix brackets on your calculator, they are just placeholders for what you put into the statement. The [variable] is a loop variable - your counter. [start] is the starting value for your variable, usually 0 or 1, [end] is your end value, and [increment] is the amount that the value changes each time, which is usually 1, especially in delay loops. If the increment is 1, then you can omit the final ,1 at the end of the statement. Make sure you use a negative increment if your stop value is lower than your start value. A For() block closes with an End statement.

A While statement uses the following simple syntax: While [expression] where [expression] can be any mathematical, logical, or mixed expression. It will loop as long as the expression DOES NOT evaluate to 0 - in the case of logic statements, as long as the expression DOES NOT evaluate to false. Repeat statements are exactly the opposite, they loop when the statement evaluates to false or 0. Like For() statements, Repeat and While statements close with an End statement.


Tutorials Home | 1


News | Downloads | Who? | Tutorials
1