### The Basics

**Calculator programming is easy once you learn what each function does.**

Here is a list of functions and what you need to do to...uhh...make them work.

*Examples are shown underneath in italics*

**{**Brackets show actual code**}**

- Input - The format for this is to put a title in quotes followed by ",
* variable*". This will produce a line like the one below

*{Input "Number of Apples:", A} shows "Number of Apples:" on the screen and stores the inputted number of apples into variable A*

Or just put a variable for simply saving an input number into the variable

*{Input A} creates a line "?" and the inputted number is stored to A*

- Prompt - Enter the name of a variable to create a line like "
*variable*=?" for input

*{Prompt A} creates the line "A=?" and the input is stored to A*

- getKey - The 'button code' of the last key pressed is returned. If no key is pressed getKey = 0; The button code is a 2 or 3 digit number, a combination of two different numbers; the first is the row it's in, the second is the column it's in.

Essential for game-making.

*Button code for the 2nd key (2nd row, 1st button) = 21 on most Ti calculators*

- Rcl - Recall - Imports the number value, picture, program lines, etc. of the specified target

- RcGDB - Recalls graph data already saved (save by using StGDB when on the y= screen; you need to put a DispGraph function after this

- RcPic - Recalls screenshots to the graph window (save screenshots with the StPic function on graph window); you do not need to put a DispGraph function after this

- InpSt - Some calculators have this, this allows words or letters to be stored into a variable

- The key STO-> creates an arrow on the screen, any number on the left side of the arrow will be stored to any variable on the right

*{5 -> A} stores 5 to variable A*

- Disp - The simplest output function, used to recall variables or print words onto the screen

Each Disp command forms a new line.

Follow with a variable or something in quotes

*{Disp A} displays the value assigned to A on the right side of the screen*

{Disp "HEY!"} displays the word HEY! on the left side of the screen

- Output( - A more sophisticated version of Disp; Requires 2 numbers for position and then has a simple Disp command

Variable outputs need to be closed with parentheses '**)**'; text outputs do not or won't work if they are

*{Output(3,4,A)} will display the number assigned to A in the 3rd row from the top and the 4th row from the left*

{Output(3,4,"BOOM!"} will display BOOM! in the 3rd row from the top and the 4th row from the left

- DispGraph - This function shows the graph window where graphs or pictures can be displayed

- ClrHome/ClLCD - This clears the main screen (where you actually use the calculator...as a calculator)

- ClearDraw - Clears the graph window except for y= functions, which will be redrawn automatically, against your will

The following functions can be found under the Draw menu, they obviously draw on the graph window based on given information

- Line( - Simply supply the coordinates of 2 points and a line will be drawn between them

*{Line(3,4,7,8)} will draw a line from a point with coordinates (3,4) to a point with coordinates (7,8)*

- dot( - Draws a point at specified coordinates...as if you couldn't figured that out on your own

*{dot(5,6)} draws a point at coordinated (5,6)...whoopee...*

- PtOn( - the exact same thing as the aforementioned dot( function

- PtOff( - the exact same thing as the aforementioned PtOn( function, except it removes a point from that spot

- PtChg( - whoa...déjà vu all over again...The EXACT SAME THING as the previous 3 functions only it draws a dot if there isn't one there OR erases one if there is one there

- Shade( - Add two y coordinates to shade an area

- smaller number first:
**The Eternal Blackness of Death and Despair!**
- larger number first: The Unexciting Parallel Lines...
**of Death and Despair!**

*{Shade(-10,10)} fills the area between 10 on the graph screen and -10 with black*

{Shade(10,-10)} creates two parallel lines, one at 10 on the graph screen and one at -10

You can also shade boxes by using the first two parameters as normal but adding 2 more for edge limits

*{Shade(-10,10,-5,5)} will shade between 10 and -10 vertcally and 5 and -5 horizantally*

- Vert( - Only one number needed: x coordinate. Draws a vertical line at specified x coordinate

- Circle( - Three numbers needed: coordinates and radius.

*{Circle(8,3,1.5) draws a circle with its center at (8,3) and with a radius of 1.5*

- DrawF - Graphs a function in terms of X

*{DrawF Y*_{1}}
{DrawF Y_{1} - 5} draws the function assigned to Y_{1} only 5 Y's lower

(directly from the manual)**Note: You cannot use a list in ***expression* to draw a family of curves

- DrawInv - Graphs the inverse of a function

*{DrawInv Y*_{1}} draws the inverse of Y_{1}

Use the following functions to alter the graph window

- AxesOff - Removes the x and y axes from the graph window

- AxesOn - Displays the x and y axes on the graph window

- Zoom - Oh boy...There are several different Zoom settings each changing the area shown on the graph screen:

- Box - Allows you to draw a square to set the new viewing area

- Decimal - Sets the screen to view from -1 to 1 on both the x and y axes

- Integer - Sets the screen to view from 1 to 10 on both the x and y axes

- Fit - Readjusts the Y max and min to show the highest and lowest values between the current X max and min

- Previous - Returns to the last zoom setting

- Stat - Readjusts the window to show all statistical points

- Square - Adjusts the screen so that each x and y are intervaled equally; circles are actually circles and squares actually squares

- Standard - Sets the screen to view from -10 to 10 on both the x and y axes

- ZoomSto - Stores the current zoom setting

- ZoomRCL - Recalls the stored zoom setting

- Zoom In - Magnifies the area around the cursor to show more detail

- Zoom Out - Widens the current viewing area

Of course you can always set the window manually by using the Window screen. The Min value is the lowest value displayed on that axis(X-Min, Y-Min). The Max value is the highest value displayed on that axis(X-Max, Y-Max).

These are the commandos. These bad boys give the orders mercilessly and only obey you. They can tend to make you feel real important. They can also drive you absolutely crazy

Here is the list of s for nearly every control function

- = or = = - equal to

- =/= - not equal to

- < - less than

- > - greater than

__<__ - less than or equal to

__>__ - greater than or equal to

- % - divides by a number and tests if the remainder equals 0

*{A%5} - divides A by 5 and tests to see if the remainder is 0*

Okay, now that that's over with, here are the commandos:

- End - closes a control function, essential for If-Then statements, For functions, and While commands. Please note that some Ti calculators have specific end functions for specific functions. Known examples: Ti-89, endif, endfor, and endwhile. Just use these according to syntax in place of a regular End function.

- Pause - Pauses the program until Enter is pressed

- Stop - Exits the program

- If( - A simple function that completes the immediately following line if the logical test is true.

'= =' works better than '=', in fact {If (blah)=(bleh)} is sometimes read as {If(blah)=/=(bleh)}

*{If A=5*

Disp "A=5"}

This simple two line command checks to see if A is equal to 5, if it is it displays A=5, if not, it skips the following line (Disp "A=5") and continues the program

- Then - For more advanced If commands; Else command is needed to make this work also. The If function runs and if the logical test is true, it performs all the commands under Then, if not, it performs all the commands under Else.

Closed with an End command

*{Prompt A*

If A= =5

Then

Disp "A=5"

Stop

Else

Disp "A≠5"

Stop

End}

This program tests A=5 then performs accordingly; this program in complete and can be put directly into your calculator for testing

- Else -
*See Then*

- For( - For is a loop function. It loops a specified amount of times. End is required for loop to work

For(*variable*,*# for variable to start on*,*# for variable to end on*,*increment*)

*{For(A,1,5,1)*

command

End}

This will repeat the command 5 times

- While - This is another looping function, it works like the If function. End is required for to work

While *logical test*

{While 1} produces an infinite loop

*{While A<56*

Disp A

A+1->A

End}

This program counts to 55. And now for my famous, infinitely counting program:

{1 -> A

While 1

Disp A

A+1->A

End}

"WHY CAN'T IS STOP THIS THING?!"? - Press the ON button, no memory will be erased, relax

- Repeat - This repeats until the logical test is true or while it is false

I guess the infinite loop for this would be {Repeat 1= =1} or any similar function
*{1->A*

Repeat A>5

Disp A

A+1->A

End}

This simple program counts until A is greater than 5, or counts up to 5

- IS> - increment and skip - Place a variable and a target after this. 1 will be added to the variable and tested to be greater than the number.

**IS> is not a looping function, sorry**

__Format__

IS>(*variable*,*#*)

*command for if false (if variable + 1*__<__#)

command for if true (if variable + 1 > #)

- DS< - decrement and skip - Nearly identical to the IS> function

**DS< is not a looping function, sorry**

__Format__

DS<(*variable*,*#*)

*command for if false (if variable + 1*__>__#)

command for if true (if variable + 1 < #)

- Lbl - any letter or symbol after this will create a marker at this point; use with Goto function below

- Goto - the letter or symbol used for the desired Lbl point will immediately and quickly (great for fast loops) warp to the specified Lbl point

*{1->A*

Lbl B

Disp A

A+1->A

Goto B

Bet this'll loop faster than the previous counting program!

- Menu( - Okee...this one's a bit tricky...

__Format__

Menu(*"title", "first item", letter(for built in Goto command), "second item", second letter, etc.*

**Example:**

__Code__

{Menu("TOSS DICE","FAIR DICE",A,"WEIGHTED DICE",B)}

__Output__

**TOSS DICE**

1: FAIR DICE

2: WEIGHTED DICE

*When an item from the menu is selected, the program runs a Goto function with the assigned letter. So, in this case, if "FAIR DICE" is selected, the program will run {Goto A}. It is crucial that you finish the program with a Lbl A in order for it to perform the correct function.*

Also, this particular format may not work on certain calculators like my Ti-85...wish I could help ya guys...

#### Calling

OK...one last thing..."calling". By putting the name of a another program into your program (actually there's a menu that should display a list of all the other programs to choose from. When the program reads the other program's name, it will execute that program. But there's one catch, you need a special function instead of Stop in your secondary function:

- Return - Put this bad boy at the end of your secondary program or when you want it to return to the main program. This can also be used in a program to bring up the main screen again.

__Program A__

{Input "A=",A

If A>5

Program B

If A__<__

Output(4,1,"A is less than 5"}

__Program B__

{Output(4,1,"A is greater than 5"

Return}

In this example, Program A calls Program B. Of course in this case it is not necessary and this function is not normally used. This function should be used to tie several programs together in a Menu and use the Lbl's to call other programs

Well, that's it! Thank you for flying Kilroy Airlines, your nearest exits are here, and here, and enjoy the rest of your stay here in Everything2.com