Variables are the heart of out little endeavor. If you don't understand variables, you wont be able to do anything, so read this section slowly. There are several important types of variables which we will discuss.
A. Expressions
The most common of these variables is the expression. Usually an expression will be a
real, like 5 or 3.14, but can also be
complex, like 5+2i. Expressions can also call other variables (ex 5+x).
When an expression is used like this, it's value will be simplified if the variables are not defined.
IMPORTANT: If a variable calls another variable, which is defined, and this variable is used in defining another variable, the new variable will not contain the defined var. That doesn't make much sense, so try this: Suppose A=1+x and x=7. If we recall A, it will be 8. If we define B as A+1, B will be 8, but B will not change if x changes. A will. Go back and read that again. Similarly, if x is already defined when we store x+1 as A, A will be constant. To avoid this, yu could define A as a function, but don't worry about that. To define an expression type
expr->var.
IMPORTANT: If x is not defined and you type x+1->x, you will recieve a circular definition. If x is defined, this will simply increase x by 1.
B. Equations
You probably won't store equations as variables unless you are writing a math program. Define an equation variable by typing
equ->var (ex. 5+x=y->E). Again, once some of the variables in the equation are defined (x or y in the above example), the equation will be simplified, but will change again if the variable values change. If the calculator can prove the equation is true or false, it will output true or false. (This can be used with conditional statements.)
C. Lists
A list is a set of expressions (and sometimes strings). Define a list by typing {
expr or string,expr or string,...}->var. You can recall one element of the list by typing
var[
element number]. This value can be treated like any other variable of its type. Use dim(
var) to get the number of elements in the list.
D. Matrices
A matrix is similar to a list in two dimensions. Define a matrix by typing [[
expr or string,expr or string,...][
expr or string,expr or string]...]. You can recall a row of a matrix by typing
var[
rownumber]. You can recall any element by typing
var[
rownumber,colnumber]. Dim(
var) will return a list {number of rows, number of col}.
You can convert between lists and matrices using list>mat or mat>list.
E. Data
Data Sets are sets of lists. They are most easily created using the data editor, but you can use NEWDATA
list,list,... To recall the list in a column, type
var[
col]. To recall an element of one of the lists, type
var[
colo][
elementnumber]. If you don't understand data sets, don't worry.
F. Strings
To define a string, type "
string"->
var. To recall a portion of a string use LEFT(
var,numberofcharacters), RIGHT(
var,numberofcharacters), or MID(
var,startingpoint,numberofcharacters). To parse two strings together, use
string&
string. To convert an expression into a string, use STRING(
expr). To convert a string to an expression, use EXPR(
string). DIM(
string) returns the number of characters in the string. To recall the variable with the name which is stored in a string, use #(
string). This is important, but confusing, so I'll elaborate on that later.
G. Pictures
To define a picture, use STOPIC(
Var,row,col,width,height) or NEWPIC(
mat). I will say very little about NEWPIC because it is slow and pretty useless. I have no idea why TI implemented it the way they did. Oh well.
To recall a picture, use RCLPIC
var,row,col, RPLCPIC
var,row,col ANDPIC
var,row,col, or XORPIC
var,row,col. You will usually use RCLPIC, which turns on pixles which are black in the picture file, and RPLCPIC, which also turns off pixels which are already on.
H. Variable management
You can use ARCHIVE
var,var,... and LOCK
var,var,... to archive or lock variables. (WOW!)
IMPORTANT: ARCHIVED and LOCKED variables cannot be changed. UNARCHIV and UNLOCK undo these processes. Use DELVAR
var to delete a variable. Use MOVEVAR
var,oldfolder,newfolder to move variables. Use NEWFOLD
fold to create a new folder. Try to use local variables whenever possible.
You don't need to understand everything I just said right now. Most of the complicated features I'll get back to. You do need to understand the differences between the types of var and the associated functions. If you can answer these questions, you're in good shape.
Quiz 1: Variables
What will be displayed when the following code is executed?
1.
Demo1()
Prgm
{1,23,3,7,5,3,7,4,0}->A
A[4]->B
B+x->F
Disp F
EndPrgm
Answer: 4+x
2.
Demo2()
Prgm
[[1,2,3][3,2,1][4,2,6]]->A
dim(A)->F
Disp F
EndPrgm
Answer: {3,3}
3.
Demo3()
Prgm
5=3+y->F
4->Y
Disp F
EndPrgm
Answer: false
4.
Demo4()
Prgm
Prompt A
"You entered "&string(A)->F
Disp F
EndPrgm
Answer: ex: You entered 5 (if the user entered 5)
Good. By the way, none of the above examples is anywhere near as efficient as it could be. Now that you understand variables, we can move on to everything you ever wanted to know about output.