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 anerror. 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 andruntime errors.
For example, consider the following example:
The syntax for theOutput( 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:
ERR:ARGUMENT1:Quit2:Goto
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:
A=?4 .25
However, consider when the user inputs0:
A=?0 ERR:DIVIDE BY 01:Quit2:Goto
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:If A≠0 beforeDisp would prevent an error.
Runtime errors do not necessary have to display an error to be anerror. 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!
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 inL1, but contains an error. Find, identify, and fix the error.
Solution |
|---|
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 inL1 (this program assumes there is at least one value inL1).
Solution |
|---|
The error is on line 4. The given program stores the index of the largest number toL, where it should store the value itself. The fixed program:
In the future, just usemax(. |
Previous:Menus
Next:Tips, Tricks and Optimizations
Table of Contents:TI-Basic Z80 Programming