TI-Basic Z80 Programming/Errors

When programming on the TI-84, the calculator will assume the written code is valid. If, as it executes the code, finds an unexpected token, or encounters an otherwise invalid statement, the TI-84 will throw an error. The calculator will stop executing the code in the program and display the type of error on the screen. There are two types of errors: syntax errors and runtime errors.

For example, consider the following example:

The syntax for the Output( command expects two integers, then a string. In this example, the second argument is a string, which the calculator does not know how to interpret. In this case, the calculator throws an error:

Code execution halts and a menu is displayed. The first option quits the program and returns to the home screen. The second option will open the code editor and scroll to the line in the code where the error occurred.

The second type of error is a runtime error. These errors can't necessarily be detected by the appearance of code. Consider the following example that displays the reciprocal of the entered value:

The code works fine in most scenarios:

However, consider when the user inputs :

This behavior can be unwanted, since the code halts and does not continue executing if an error occurs. Therefore, it is important to consider all edge cases for calculations and statements. In this case, the line  before Disp would prevent an error.

Runtime errors do not necessary have to display an error to be an error. For example, a program that is expected to display the even letters of the alphabet, but instead displays the odd letters of the alphabet, would have a runtime error since the program does not function as expected. These can be the hardest and easiest errors to fix!

You try it!
Examine the following examples, identify which kind of error is presented, and a fix to resolve the error(s).

The following program should store 10 random numbers in L 1 , but contains an error. Find, identify, and fix the error.

The error is on line 3. The given program uses square brackets ([ and ]) instead of parenthesis. The same program with the error fixed:

In this example, the program should output the largest number in L 1  (this program assumes there is at least one value in L 1 ).

The error is on line 4. The given program stores the index of the largest number to L, where it should store the value itself. The fixed program:

In the future, just use <tt>max(</tt>.