Disaster

The abbreviation "asm" is ambiguous and may refer to:

• Asm(, the command used for running a shell-independent assembly program.
• Assembly, the other programming language available on the TI graphing calculators.

If an internal link led you here, you may wish to change the link to point directly to the intended article.

The ListPages module does not work recursively.

# Horizontal Sprites

## Explanation

In order to create a text sprite, one must have a series of characters and each character returns a certain number of pixels in certain arrangement on the graphscreen. Each character, when displayed on the graphscreen will return certain pixels in its first column of text. For example, if one displayed the letter "J" to the graphscreen it would look like this: (0 = empty pixel, 1 = filled pixel)

001
001
001
101
111


The first column of text is therefore "00011." The value, 00011b, (in binary) is equivalent to the decimal value 3. Each character, when displayed on the graphscreen will such a number associated with it. Therefore it is easy to organize all the possible text sprites numerically.

You can create rows of text spites this way. You could then stack these rows up from bottom to top to fill large portions of the screen. An important thing to remember though, is that vertical text sprites are much faster for larger images. They can fill the entire screen in just 4 seconds on an 84!

## Chart

This chart contains the best characters to use for each pixel combination when drawing a text sprite:

1. Each is at most three pixels wide (not counting the 1-pixel margin to the left of each character).
2. When possible, they are 1-byte characters, or if not, at least commonly accessible.
Char. Binary Decimal Char. Binary Decimal
space 00000b 0 ? 10000b 16
. 00001b 1 ] 10001b 17
mark 00010b 2 2 10010b 18
J 00011b 3 2 10011b 19
+ 00100b 4 x 10100b 20
í 00101b 5 $\definecolor{darkgreen}{rgb}{0.90,0.91,0.859}\pagecolor{darkgreen} \overline{\mathrm{x}}$ 10101b 21
e 00110b 6 û 10110b 22
mark 00111b 7 $\definecolor{darkgreen}{rgb}{0.90,0.91,0.859}\pagecolor{darkgreen} i$ 10111b 23
^ 01000b 8 Y 11000b 24
1 01001b 9 Î 11001b 25
: 01010b 10 $\definecolor{darkgreen}{rgb}{0.90,0.91,0.859}\pagecolor{darkgreen} \chi$ 11010b 26
none 01011b 11 X 11011b 27
º 01100b 12 ' 11100b 28
s 01101b 13 ! 11101b 29
( 01110b 14 Q 11110b 30
u 01111b 15 [ 11111b 31

# Vertical Sprites

## Differences with horizontal sprites

The main difference for a vertical sprite is that you need only one text( command to fill an entire horizontal line. It has a noticeable advantage on horizontal sprites when sprites are larger. It is not only faster but you are not limited to a 5x5 sprite or a 7x7 sprite. Also, you don't use a picture variable which can be more convenient in some situations. You don't need to group Pics and your program in order to send it to someone.
In order to draw a sprite, you must draw from bottom to top in order to not erase what is already written. The main disadvantage is that only ∟ , N and … don't end with a 0. But it really doesn't matter, because you can make any vertical sprite using only the ., [, and the ∟. In conclusion, if you need to draw large sprites or even to fill the graphscreen, you should use vertical sprites, otherwise horizontal sprites are for you.

:Text(9,1,"1
:Text(8,1,"Δ
:Text(7,1,"Ω
:Text(6,1,"Δ
:Text(5,1," 1
:Text(4,1,"     //5 spaces


## Chart

This chart contains characters from 1 to 6 pixels wide. A 0 represents an empty pixel while a 1 is for a black pixel. If you need a character larger than 6 pixels wide, you can search in Weregoose database here.

Char. Binary Char. Binary Char. Binary Char. Binary
space 0 - 0000 00100 * 001000
: 00 4 0010 σ 01000 010000
. 10 0 0100 û 01010 w 010100
 000 { 0110 É 01110 @ 011100
( 010 F 1000 μ 10000 m 100010
) 100 A 1010 ñ 10010 n 100100
N 101 } 1100 ß 10100 10 101110
[ 110 1 1110 È 11100 Ω 110110
111 ° 00000 z 11110 $111100 Δ 111110 # Also see Text Sprite Finder - this program is a compact version of what is on this page, this page simply explains how this program fundamentally works. Vertical Sprites Bottom Row - to have a complete database with the bottom row of all TI-83/84/+/SE characters. Graphics - for information on using text sprites. Binary and Hexidecimal - to understand how to read the binary format. TI-83 Plus Large Font - for clarification on which characters are being referred to. CHARS.8xp - A program that contains many otherwise unobtainable characters. Text Sprite Generator - A drawing program that outputs the text sprite code to display the sprite. If you have ever played any of the snake, mofrog, nibbles, etc. games, then this game should be familiar to you. The basic premise is to go around eating food and the snake grows longer with each piece of food. However, this snake game has an additional element to it: you need to constantly change directions to keep the snake moving fast. Like with the other games, try out the game and try to understand and think through the code.  Table of Contents ## The Code :26-2int(2rand→K :{4→L1:Ans→L2:1→I :ClrHome :For(J,1,E2 :L1(1→L1(J :L2(1→L2(J :Repeat max(S≠L1 and Ans≠L2 :randInt(1,8→S :randInt(1,16→T :End :Output(S,Ans,"* :Repeat T=Ans and S=L1(I :getKey :If Ans=45:Goto Q :If Ans=34 or 2>abs(Ans-25:Ans→K :I+1-J(I=J→I :Output(L1(Ans),L2(Ans)," // 1 space :(K=34)-(K=25)+L1(Ans-(Ans>1 :Ans+8(not(Ans)-(Ans=9→L1(I :(K=26)-(K=24)+L2(I-(I>1 :Ans+16(not(Ans)-(Ans=17→L2(I :Output(L1(I),Ans,"O :End:End :Lbl Q :ClrHome:J  ## The Download In case you want to try the program on your calculator, you can download the program in .8xp format. Whee! You got through the first part of the starter kit! Now, we come to the second part, which will get into the finer points of the homescreen and data types. We will start off the second part of the kit by discussing more of the homescreen. Let's begin, shall we? # Letting the User See Something Back in the first part, you only learned of one command that can display information, the Disp command. We will learn two more commands that deal with output, starting with the ClrHome command. ## ClrHome The ClrHome command clears the homescreen, giving you an empty space to work with. No arguments are needed, just select it from the I/O menu of the PRGM button (only accessible this way while editing). Two Notes 1. Output( will write over anything on the homescreen 2. Disp, Input, and Prompt will not recognize Output( commands, so if you have some text printed at 1,1 and then use Input, you will write over the Output( ## Output The Output( command lets you print text, just like the Disp command. There are two differences, though: You can choose where to start the text, and strings that go off the end of the screen will wrap around to the next line! To use it, you need three arguments: the row where the first character appears, the column, and the text. You use it like so: :Output(8,1,"PRESS ENTER")  This text starts at the bottom-left corner of the screen, and prints PRESS ENTER. The most useful application for Output( is to dynamically update the home screen. If you had money in the top left corner and life in the bottom left for a game, using Disp to update those would be a pain. You would have the un-updated text blink, because you had to ClrHome first. Output allows you to avoid the flicker. # Making the Program Smart In the past, you only knew of the Input command for input. Now we will cover two more input methods, the first being Prompt. ## Prompt Prompt is a much more primitive command than Input, but it gets the job done. It only needs one argument: the variable. You can add more variables to one Prompt statement, as long as they are separated by commas. Here is a basic use: Prompt A  The code will show A=?, which means, "What do you want A to equal?". Prompt has limitations, and quality programs are unlikely to use it because the A=? thing doesn't look very professional. The limitations are outlined below: • Cryptic - Prompt doesn't allow custom text to be displayed, unlike Input. The casual calculator user can be intimated by the cryptic look that is forced. • No Exception - If you want someone to enter a string using Prompt, the user must put quotation marks around the string or risk error. Input doesn't care. # Final Notes These are the last of the commands that can directly influence the home screen. The furthest from direct influence is getKey, which you will discover in detail in the next lesson. More on the commands you just learned can be found on their respective pages. Try searching for them in the upper right hand corner of the site! Hopefully you can use the homescreen commands well. Next up we explore the hidden elements of input: data types, and the getKey command.  Name: Vortex Author: Builderboy2005 Download: Vortex.zip Compatibility: Parent page not set File Size: 3,964 Bytes Vortex is a fun, challenging, turn-based multiplayer strategy game. The object of the game is to kill your opponent. You can go around collecting boxes of money and use them to buy upgrades, items, and weapons. The game also features a random level generator. Fully MirageOS compatible. Matrices are a step up from lists. Lists are a string of elements, like {5,4,3,2,1,0}. A matrix, on the other hand, is a list of lists, like [[5,5,5],[4,4,4],[3,3,3],[2,2,2]]. Below, we will start learning how to handle this more complex data type.  Table of Contents # Setting up Matrices Unfortunately, unlike lists, there is no SetUpEditor command to make it easy for matrices. Fortunately, though, matrices [A] through [J] always exist, unless otherwise removed. This gets rid of the need to dim( first. You do need to be careful with UnArchive. To ask if the user has already run the program, you could use a routine such as the following: :Menu("CONTINUE?","YES",Y,"NO",N) :Lbl Y :UnArchive [J] :Lbl N :{2,3}→dim([J])  What does that last line of code do? Well, this is just like setting the size of lists in the last lesson. The only difference is that we need to have two numbers that are separated by a comma and surrounded by curly braces. The last line of code above says to give matrix [J] 2 rows and 3 columns. If you prefer to think of matrices as lists of lists, you can say that the last line of code says, "Provide 2 lists, each with 3 elements." # Using Matrices ## Writing It is really simple to store an element into a matrix. To store the number 5 into row 1 and column 2 of our matrix [J], we use this line: :5→[J](1,2)  Simple, right? What if you want to store the powers of 2 from element (1,1) to (2,3)? We have to use this code: :{2,3}→dim([J]) :0→P :For(R,1,2) :For(C,1,3) :P+1→P :2^P→[J](R,C) :End :End  Notice how it is a lot more complicated than the version with the list. This is because we first start the For( loop for both rows of our matrix, and then within that we start the For( loop for every column of the current row. ## Reading Let's make this simple. To store a matrix element to a variable, use this line of code: :[J](1,2)→A  This stores element (1,2) of [J] into the real variable A. To display it, use this line: :Disp [J](1,2)  Now, let's modify our program to show some results. :ClrHome :{2,3}→dim([J]) :0→P :For(R,1,2) :For(C,1,3) :P+1→P :2^P→[J](R,C) :Disp [J](R,C) :End :End  We've added a ClrHome command to the beginning, and a Disp command above the two Ends. If you do it right, your output should be: 2 4 8 16 32 64 Done # Cleaning Up Fortunately, you just need to use the Archive command for a matrix to be archived. # Final Notes Now, you see how much more powerful a matrix is, when coming from a list. Matrices are usually used to store map data and such. Still, the bigger step up is the string data type. This is the most powerful variable type, and you will learn about it next.  Name: Portal Author: Builderboy Download: Portal.zip Compatibility: Parent page not set File Size: 9,405 Bytes In Portal, you are a test subject at The Aperture Science Enrichment Program and are testing The recent invention of the Portal Gun! Yay! It allows you to shoot portals and move between them. Those who have played the official version will remember GlaDos… And she's back in the calculator version! GlaDOS is your narrator and guide and is the one that will monitor all your tests. But when the tests are over… Watch out! the game isn't over yet…  Name: Minigame Party Author: 7thAce Download: Minigame-Party.zip Compatibility: Parent page not set File Size: 7,856 Bytes This is a game package. There are 4 games in there now, and 4 more will be coming. Press 2nd to play them all in order. Just read the readme :)  Name: Mnemon Author: Mapar007 Download: Mnemon.zip Compatibility: Parent page not set File Size: 1,073 Bytes This is a program to create data sheets and read them. You must input a random code of 6 letters/numbers which form your personal ID. It will mace secure that nobody else can read your data sheets on their calculator! (note:do not pick MNEMON as a code, unless you want everyone to be able to read your files!)  Name: Move Author: Mapar007 Download: Move.zip Compatibility: Parent page not set File Size: 2,674 Bytes Game in which you must collect O's with an X without stepping the *'s  Name: Bunny Gotchi Author: James Kanjo Download: BunnyGotchi_1-7.zip Compatibility: Parent page not set File Size: 6,637 Bytes Bunny Gotchi is a virtual pet (a bunny rabbit) on your calculator. Bunny Gotchi is one of the few "Tamagotchi" programs available to the TI-83plus, and fewer still containing animations. It will challenge your efforts to keep it alive, healthy and happy! Version 1.7 is architecturally identical to version 1.6, but is 483 bytes smaller. [[include inc:tablet |name= |author= |size= |description= |picture= |downloadUrl= |downloadName= ]] ## |name= Type in the name of the program. ## |author= Type in the name of the Author. Alternatively, you can include a URL link to the author's page by typing in: [URL Author's Name] ## |size= Type in the size of the program as it appears on the calculator. Make sure to include any subprograms, variables, pictures, or anything else that is included with the program. • If the program size is under 20,000 bytes, use bytes: 17,235 Bytes • If the program size is over 20,000 bytes, use KB: 23KB ## |description= Enter a brief description about the program. ## |picture= Type in: FULL-URL If nothing is entered, a default image will appear instead. ## |downloadUrl= Type in the full URL of the program file. ## |downloadName= Type in the name that you want to appear for the program file's download: File.zip.  Name: No name given Author: No author given Download: Download Unavailable Compatibility: Parent page not set File Size: No size given No description given author: 'Robert Moy (Harrierfalcon)' description: 'Metroid Pi is a pure TI-Basic version of the classic Metroid game, with the game following the standard storyline of making your way through several increasingly difficult areas, while battling enemies, bosses, and getting powerups that allow you to beat the next area in the game.' arcade: '0' graphics: '0' platform: '1' puzzle: '0' rpg: '1' strategy: '0' sports: '0' casino: '0' board: '0' utility: '0' misc: '0' image: /metroid-pi/metroidpi.gif download: metroidpi.zip size: '17016' unit: '1'  Name: {$name} Author: {$author} Download: [{$downloadUrl} {$downloadName}] Compatibility: {$compatibility} File Size: {$size} {$description}
 Name: Donut Quest Author: Mikhail Lavrov (DarkerLine) Download: DonutQuest.zip Compatibility: Parent page not set File Size: 10,154 Bytes Donut Quest is a TI-Basic game of revolutionary quality. It uses no libraries of any kind, in fact, you don't need anything other than the game program to play it. On each of eight levels, you must get to (and eat) all the donuts, then leave through an exit (unless given other instructions).

Binary, hexadecimal, and octal refer to different number systems. The one that we typically use is called decimal. These number systems refer to the number of symbols used to represent numbers. In the decimal system, we use ten different symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. With these ten symbols, we can represent any quantity. For example, if we see a 2, then we know that there is two of something. For example, this sentence has 2 periods on the end..

When we run out of symbols, we go to the next digit placement. To represent one higher than 9, we use 10 meaning one unit of ten and zero units of one. This may seem elementary, but it is crucial to understand our default number system if you want to understand other number systems.

For example, when we consider a binary system which only uses two symbols, 0 and 1, when we run out of symbols, we need to go to the next digit placement. So, we would count in binary 0, 1, 10, 11, 100, 101, and so on.

This article will discuss the binary, hexadecimal, and octal number systems in more detail and explain their uses.

# How a Number System Works

Number systems are used to describe the quantity of something or represent certain information. Because of this, I can say that the word "calculator" contains ten letters. Our number system, the decimal system, uses ten symbols. Therefore, decimal is said to be Base Ten. By describing systems with bases, we can gain an understanding of how that particular system works.

When we count in Base Ten, we count starting with zero and going up to nine in order.

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, …

Once we reach the last symbol, we create a new placement in front of the first and count that up.

8, 9, 10, 11, 12, … , 19, 20, …

This continues when we run out of symbols for that placement. So, after 99, we go to 100.

The placement of a symbol indicates how much it is worth. Each additional placement is an additional power of 10. Consider the number of 2853. We know this number is quite large, for example, if it pertains to the number of apples in a basket. That's a lot of apples. How do we know it is large? We look at the number of digits.

Each additional placement is an additional power of 10, as stated above. Consider this chart.
103 102 101 100
digit digit digit digit
*1000 *100 *10 *1

Each additional digit represents a higher and higher quantity. This is applicable for Base 10 as well as to other bases. Knowing this will help you understand the other bases better.

## Binary

Binary is another way of saying Base Two. So, in a binary number system, there are only two symbols used to represent numbers: 0 and 1. When we count up from zero in binary, we run out of symbols much more frequently.

0, 1, …

From here, there are no more symbols. We do not go to 2 because in binary, a 2 doesn't exist. Instead, we use 10. In a binary system, 10 is equal to 2 in decimal.

We can count further.

 Binary Decimal 0 1 10 11 100 101 110 111 1000 1001 1010 0 1 2 3 4 5 6 7 8 9 10
Just like in decimal, we know that the more digits there are, the larger the number. However, in binary, we use powers of two. In the binary number 1001101, we can create a chart to find out what this really means.
26 25 24 23 22 21 20
1 0 0 1 1 0 1
64+0+0+8+4+0+1
77

Since this is base two, however, the numbers don't get quite as large as it does in decimal. Even still, a binary number with 10 digits would be larger than 1000 in decimal.

The binary system is useful in computer science and electrical engineering. Transistors operate from the binary system, and transistors are found in practically all electronic devices. A 0 means no current, and a 1 means to allow current. With various transistors turning on and off, signals and electricity is sent to do various things such as making a call or putting these letters on the screen.

Computers and electronics work with bytes or eight digit binary numbers. Each byte has encoded information that a computer is able to understand. Many bytes are stringed together to form digital data that can be stored for use later.

## Octal

Octal is another number system with less symbols to use than our conventional number system. Octal is fancy for Base Eight meaning eight symbols are used to represent all the quantities. They are 0, 1, 2, 3, 4, 5, 6, and 7. When we count up one from the 7, we need a new placement to represent what we call 8 since an 8 doesn't exist in Octal. So, after 7 is 10.

 Octal Decimal 0 1 2 3 4 5 6 7 10 11 12… 17 20… 30… 77 100 0 1 2 3 4 5 6 7 8 9 10… 15 16… 24… 63 64

Just like how we used powers of ten in decimal and powers of two in binary, to determine the value of a number we will use powers of 8 since this is Base Eight. Consider the number 3623 in base eight.

83 82 81 80
3 6 2 3
1536+384+16+3
1939

Each additional placement to the left has more value than it did in binary. The third digit from the right in binary only represented 23-1, which is 4. In octal, that is 83-1 which is 64.

## Hexadecimal

The hexadecimal system is Base Sixteen. As its base implies, this number system uses sixteen symbols to represent numbers. Unlike binary and octal, hexadecimal has six additional symbols that it uses beyond the conventional ones found in decimal. But what comes after 9? 10 is not a single digit but two… Fortunately, the convention is that once additional symbols are needed beyond the normal ten, letters are to be used. So, in hexadecimal, the total list of symbols to use is 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, and F. In a digital display, the numbers B and D are lowercase.

When counting in hexadecimal, you count 0, 1, 2, and so on. However, when you reach 9, you go directly to A. Then, you count B, C, D, E, and F. But what is next? We are out of symbols! When we run out of symbols, we create a new digit placement and move on. So after F is 10. You count further until you reach 19. After 19, the next number is 1A. This goes on forever.

 Hexadecimal Decimal 9 A B C D E F 10 11… 19 1A 1B 1C… 9F A0 9 10 11 12 13 14 15 16 17 25 26 27 28 159 160

Digits are explained as powers of 16. Consider the hexadecimal number 2DB7.

163 162 161 160
2 D B 7
8192+3328+176+7
11703

As you can see, placements in hexadecimal are worth a whole lot more than in any of the other three number systems.

# Conversion

It is important to know that 364 in octal is not equal to the normal 364. This is just like how a 10 in binary is certainly not 10 in decimal. 10 in binary (this will be written as 102 from now on) is equal to 2. 108 is equal to 8. How on earth do we know this? What is 20C.38F16, and how do we find out?

Here is why it is important to understand how the number systems work. By using our powers of the base number, it becomes possible to turn any number to decimal and from decimal to any number.

## Base to Decimal

So, we know that 3648 is not equal to the decimal 364. Then what is it? There is a simple method in converting from any base to the decimal base ten. If you remember how we dissected the numbers above, we used powers, such as 24, and ended up with a number we understand. This is exactly what we do to convert from a base to decimal. We find out the true value of each digit according to their placement and add them together.

In a formula, this algorithm looks like:

(1)
$$V_{10} = v_pB^p+v_{p-1}B^{p-1}+...+v_1B+v_0$$

Where V10 is the decimal value, v is the digit in a placement, p is the placement from the right of the number assuming the rightmost placement is 0, and B is the starting base. Do not be daunted by the formula! We are going to go through this one step at a time.

So, let us say we had the simple hexadecimal number 2B. We want to know what this number is in decimal so that we can understand it better. How do we do this?

Let us use the formula above. Define every variable first. We want to find V10, so that is unknown. The number 2B16 has two positions since it has two digits. p therefore is one less than that1, so p is 1. The number is in base 16, so B is 16. Finally, we want to know what v is, but there are multiple v's. You have v1 and v0. This refers to the value of the digit in the subscripted position. v1 refers to the digit in position one (the second digit from the right). So, v1 is 2. v0 is the first digit which is B. In the case of the conversion, you must convert all the letters to what they are in decimal. B is 11 in decimal, so v0 is 11.

Now, plug all this into the formula:

(2)
\begin{align} V_{10} = 2(16^1)+11(16^0) \\ V_{10} = 2(16)+11(1) \\ V_{10} = 32+11 \\ V_{10} = 43 \\ \end{align}

Therefore, 2B16 is equal to 43.

Now, let me explain how this works. Remember how digit placement affects the actual value? For example, in the decimal number 123, the "1" represents 100 which is 1*102. The "2" is 20, or 2*101. Likewise, in the number 2B16, the "2" is 2*161, and the B is 11*160.

We can determine the value of numbers in this way. For the number 3648, we will make a chart that exposes the decimal value of each individual digit. Then, we can add them up so that we have the whole. The number has three digits, so starting from the right, we have position 0, position 1, and position 2. Since this is base eight, we will use powers of 8.

82 81 80
3 6 4

Now, 82 is 64. 81 is 8. 80 is 1. Now what?

Remember what we did with the decimal number 123? We took the value of the digit times the respective power. So, considering this further…

 3*64 6*8 4*1 192 48 4

Now, we add the values together to get 244. Therefore, 3648 is equal to 24410.

In the same way that for 123, we say there is one group of 100, two groups of 10, and three groups of 1, for octal and the number 364, there are three groups of 64, six groups of 8, and four groups of 1.

## Decimal to Base

Just like how we can convert from any base to decimal, it is possible to convert decimal to any base. Let us say that we want to represent the number 23610 in binary, octal, and hexadecimal. What we need to do is pretty much reverse whatever we did above. There isn't really a good formula for this, but there is an algorithm that you can follow which will help accomplish what we want.

(3)
\begin{align} (1) \hspace{6pt} Let \hspace{4pt} P = \operatorname{int}(\sqrt[B]{V}) \\ (2) \hspace{6pt} Let \hspace{4pt} v = \operatorname{int}(V \div B^P) \\ (v \hspace{4pt} is \hspace{4pt} the \hspace{4pt} next \hspace{4pt} digit \hspace{4pt} to \hspace{4pt} the \hspace{4pt} right) \\ (3) \hspace{6pt} Make \hspace{4pt} V = V-vB^p \\ (4) \hspace{6pt} Repeat \hspace{4pt} steps \hspace{4pt} 1 \hspace{4pt} through \hspace{4pt} 3 \hspace{4pt} until \hspace{4pt} p=0 \\ \end{align}

This algorithm may look confusing at first, but let us go through an example to see how it can be used. We want to represent 236 in binary, octal, and hexadecimal. So, let's try getting it to binary first.

The first step is to make p equal to $\operatorname{int}(\sqrt[B]{V})$. B is the base we want to convert to which is 2. The V is the number we want to convert, 236. Essentially, we are taking the square root of 236 and disregarding the decimal part. Doing this makes p become 7.

Step two says to let v equal our number V divided by Bp. Bp is 27, or 128, and the integer part of 236 divided by 128 is 1. Therefore, our first digit on the left is 1. Now, we actually change V to become V minus the digit times the Bp. So, V will now be 236-128, or 108.

We simply repeat the process until the p becomes a zero. When p becomes zero, we complete the steps a last time and then end.

So, since V is now 108, p becomes 6. 108 divided by 26 is 1. The 1 goes to the right of the 1, so now we have 11. V becomes 44 since 108-64 is 44.

# How?

Now you might be asking yourself how to read these numbers. Well, that’s not so difficult. First, I’ll give a general mathematical explanation which can be fit into one formula:

(4)
$$V=vB^P$$

In human language: the value of the cipher in the number is equal to the value of the cipher on its own multiplied by the base of the number system to the power of the position of the cipher from left to right in the number, starting at 0. Read that a few times and try to understand it.

Thus, the value of a digit in binary doubles every time we move to the left. (see table below)

From this follows that every hexadecimal cipher can be split up into 4 binary digits. In computer language: a nibble. Now take a look at the following table:

Binary Numbers 8 4 2 1 0 0 0 0 0 0 0 0 0 1 1 1 0 0 1 0 2 2 0 0 1 1 3 3 0 1 0 0 4 4 0 1 0 1 5 5 0 1 1 0 6 6 0 1 1 1 7 7 1 0 0 0 8 8 1 0 0 1 9 9 1 0 1 0 A 10 1 0 1 1 B 11 1 1 0 0 C 12 1 1 0 1 D 13 1 1 1 0 E 14 1 1 1 1 F 15

Another interesting point: look at the value in the column top. Then look at the values. You see what I mean? Yeah, you’re right! The bits switch on and off following their value. The value of the first digit (starting from the right), goes like this: 0,1,0,1,0,1,0,1,0,1,… Second digit: 0,0,1,1,0,0,1,1,0,0,1,1,0,0… Third digit (value=4): 0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,… And so on…

Now, what about greater numbers? Therefore we’ll need an extra digit. (but I think you figured that out by yourself). For the values starting from 16, our table looks like this:

Binary Numbers 16 8 4 2 1 1 0 0 0 0 10 16 1 0 0 0 1 11 17 1 0 0 1 0 12 18 1 0 0 1 1 13 19 1 0 1 0 0 14 20 1 0 1 0 1 15 21 1 0 1 1 0 16 22 1 0 1 1 1 17 23 1 1 0 0 0 18 24 1 1 0 0 1 19 25 1 1 0 1 0 1A 26 1 1 0 1 1 1B 27 1 1 1 0 0 1C 28 1 1 1 0 1 1D 29 1 1 1 1 0 1E 30 1 1 1 1 1 1F 31
For octals, this is similar, the only difference is that we need only 3 digits to express the values 1->7. Our table looks like this:
Binary Numbers 4 2 1 0 0 0 0 0 0 0 1 1 1 0 1 0 2 2 0 1 1 3 3 1 0 0 4 4 1 0 1 5 5 1 1 0 6 6 1 1 1 7 7

# Conversion.

In the latter topic I explained the logic behind the binary, hexadecimal and octal number systems. Now I’ll explain something more practical. If you fully understood the previous thing you can skip this topic.

## From decimal to binary

• Step 1: Check if your number is odd or even.
• Step 2: If it's even, write 0 (proceeding backwards, adding binary digits to the left of the result).
• Step 3: Otherwise, if it's odd, write 1 (in the same way).
• Step 4: Divide your number by 2 (dropping any fraction) and go back to step 1. Repeat until your original number is 0.

An example:
Convert 68 to binary:

• 68 is even, so we write 0.
• Dividing 68 by 2, we get 34.
• 34 is also even, so we write 0 (result so far - 00)
• Dividing 34 by 2, we get 17.
• 17 is odd, so we write 1 (result so far - 100 - remember to add it on the left)
• Dividing 17 by 2, we get 8.5, or just 8.
• 8 is even, so we write 0 (result so far - 0100)
• Dividing 8 by 2, we get 4.
• 4 is even, so we write 0 (result so far - 00100)
• Dividing 4 by 2, we get 2.
• 2 is even, so we write 0 (result so far - 000100)
• Dividing 2 by 2, we get 1.
• 1 is odd, so we write 1 (result so far - 1000100)
• Dividing by 2, we get 0.5 or just 0, so we're done.
• Final result: 1000100

## From binary to decimal

• Write the values in a table as shown before. (or do so mentally)
• Add the value in the column header to your number, if the digit is turned on (1).
• Skip it if the value in the column header is turned off (0).
• Move on to the next digit until you’ve done them all.

An example:
Convert 101100 to decimal:

• Highest digit value: 32. Current number: 32
• Skip the "16" digit, its value is 0. Current number: 32
• Add 8. Current number: 40
• Add 4. Current number: 44
• Skip the "2" and "1" digits, because their value is 0.
• Final answer: 44

## From decimal to hexadecimal.

THIS IS ONLY ONE OF THE MANY WAYS!

• Convert your decimal number to binary
• Split up in nibbles of 4, starting at the end
• Look at the first table on this page and write the right number in place of the nibble

(you can add zeroes at the beginning if the number of bits is not divisible by 4, because, just as in decimal, these don’t matter)

An example:
Convert 39 to hexadecimal:

• First, we convert to binary (see above). Result: 100111
• Next, we split it up into nibbles: 0010/0111 (Note: I added two zeroes to clarify the fact that these are nibbles)
• After that, we convert the nibbles separately.
• Final result: 27

## From hexadecimal to decimal

*Check the formula in the first paragraph and use it on the ciphers in your hexadecimal number. (this actually works for any conversion to decimal notation)

An example:
Convert 1AB to decimal:

• Value of B = 160×11. This gives 11, obviously
• Value of A = 161×10. This gives 160. Our current result is 171.
• Value of 1 = 162×1. This gives 256.
• Final result: 427

## From decimal to octal

• Convert to binary.
• Split up in parts of 3 digits, starting on the right.
• Convert each part to an octal value from 0 to 7

Example: Convert 25 to octal

• First, we convert to binary. Result: 11001
• Next, we split up: 011/001
• Conversion to octal: 31

## From octal to decimal

Again, apply the formula from above

Example: convert 42 to decimal

• Value of 2=80×2=2
• Value of 4=81×4=32
• Result: 34

# Fun Facts

OK, these may not be 100% "fun", but nonetheless are interesting.

• Do you tend to see numbers beginning with 0x? This is common notation to specify hexadecimal numbers, so you may see something like:
0x000000
0x000002
0x000004


This notation is most commonly used to list computer addresses, which are a whole different story.
• This is pretty obvious, but you can "spell" words using hexadecimal numbers. For example:
• CAB = 3243 in decimal notation.

# End

Did you understand everything? If you think so, test yourself:

Bin Dec Hex
3A
76
101110
88
1011110
47

Make some exercises yourself, if you want some more.

Lists are one of the most used data types, and they can hold up to 999 elements (the only exception is the TI-83, which can only hold 99 elements). You can also name your own lists, making it the most secure data type available on the TI-83 calculators.

Note: To programmers coming from computers, this is the equivalent of a one-dimensional array.

 Table of Contents

# Before You Start

There are two "types" of lists: predefined and custom. Predefined lists are L₁…L₆, and are accessible by pressing 2nd 1-6 respectively. The casual calculator user is probably using these, so don't use these if you don't have to. Custom lists start with a tiny uppercase ∟, and have a maximum of five characters afterward. You can have lists such as ∟LUNCH, or ∟TODO, or ∟GRR. We will be working with custom lists on this page.

# Setting Up Lists

To create a list, all you have to do is this:

:5→dim(∟LIST)


The dim( command creates the list, and the number 5 being put in it tells the list how many elements it has to have in it. But what if you archived it when the program was run last? Then, you need to unarchive it using the UnArchive command:

:UnArchive ∟LIST
:5→dim(∟LIST)


But wait, it isn't that easy! If you try to unarchive something that doesn't exist, you get an ERR:UNDEFINED error! So, we must make sure the list is created first, by using the dim( command. But, if the list does exist and it is archived, we must unarchive it first! What to do, what to do.
You could either wait until the user says whether or not the list exists (not the best choice), or you can use another command available called SetUpEditor.

## SetUpEditor

When you use SetUpEditor, you put the name of the list afterwards, like SetUpEditor ∟LIST. If the list doesn't exist, it gets created, if it is archived, it gets unarchived; and if nothing special happened to it, it just does nothing. This one command fixes what would take quite a few lines of code and the possibility of user error. You can then use the dim( command to specify the number of elements in the list. You can use it like so:

:SetUpEditor ∟LIST
:5→dim(∟LIST)


Now your list is set up! Note that for custom lists, the ∟ prefix is not required.

# Using a list

## Writing

It isn't that hard to use a list. To write something to it, for example, you use this code:

:5→∟LIST(1)


This code writes the number five the the first element of the list. (Computer programmers: the index starts at 1, not 0) To write the first 5 powers of 2 into each element, starting at the first element (with the number 2 inside), you can use this code:

:SetUpEditor ∟LIST
:5→dim(∟LIST)
:For(L,1,5)
:2^L→∟LIST(L)
:End


Inside of the For( loop, we go through each respective element of ∟LIST and store the respective power of 2 into it. The end result of the list is {2 4 8 16 32}.

## Reading

Reading from a list is just as easy. To put an element from a list into the variable X, you use this command:

:∟LIST(1)→X


To display the element without storing into the variable, you can do something like:

:Disp ∟LIST(1)


Now, what if the program we made earlier was supposed to show the results? We would modify it like so:

:ClrHome
:SetUpEditor ∟LIST
:5→dim(∟LIST)
:For(L,1,5)
:2^L→∟LIST(L)
:Disp ∟LIST(L)
:End


The first addition is at the very top. ClrHome is just a precautionary measure. The second addition is just before the End, and that is the Disp command, which displays element number L on the screen. Try out the program, and you should see on the home screen:

2
4
8
16
32
Done

# Finishing Up

You need to do, at the most, only two things to clean up your list use.

The first is to archive your list using the Archive command, if you want to protect it until next time. Or, if it is only used to hold temporary variables, you can delete it with Delvar.

The second is to SetUpEditor, like so:

:SetUpEditor


This sets up the Edit… command (on the STAT button) so that it allows edit of L₁…L₆. Don't use this, and the student who clicks on Edit… will see ∟GAME appear just as the teacher walks to check on him, and oops.

The ListPages module does not work recursively.

{$heading} Besides reading the programming information that the wiki provides, there are several additional TI-Basic tutorials and guides that other people have created that you might find handy. As quality tutorials and guides are hard to come by for TI-Basic and Assembly, some of the tutorials and guides listed here are not that great (they are unfinished or have holes in their content). Still, having the information to read and learn from is better than the converse. Name Author UCS TI-Basic Tutorial ? TI Source - TI-83+ Basic Programming ? TI-Freakware BASIC Tutorial Daniel Thorneycroft Kerm Martian's Complete TI-83/+/SE BASIC Tutorials Kerm Martian BASIC Guru Online Tutorials Ben Ilegbodu TI 83 BASIC Tutorial Jacob W. Tatay TI-83 BASIC Tutorial (Portuguese) Sérgio Santos Basic on TI-82-83+SE Yannick Wrtal Programming On The TI-82 Andy Gelzleichter BASIC Tutor Hieu-Trung Le Programming with the TI-83 Chris Neugebauer mjs2000 inc. Tutorials ? Rogue's TI-86 Basic Tutorial ? HeaneySoft BASIC Tutorial ? TI-83 Programming Tutorials Lue Her and Andy Becker TI-BASIC for noobs ? Resource Description TI-Basic IRC Channel The #Optimize channel over at United-TI is for TI-Basic code and optimization help. Besides Weregoose, the moderator, there are several other people willing and capable to help beginners (and anyone else) with whatever problems or questions they have. It is a very friendly environment. TI-Basic Sidebar The TI-Basic Sidebar is a list of the TI-83/84/+/SE commands organized alphabetically for quick reference. Clicking a command link opens up the respective command page on TI-Basic Developer in the main browser window. The sidebar appears as a bookmark in the bookmarks list, and clicking on the bookmark opens up a new frame in the browser. Routine Summary Draws an ellipse with specified coordinates. Inputs (A,B) - upper left corner, in pixels (C,D) - lower right corner, in pixels Outputs Ellipse inscribed in the rectangle from (A,B) to (C,D) Variables Used A,B,C,D for input ∟X and ∟Y store a sin/cos look-up table Plot1 to store the unit circle Pic1 to preserve background Calculator Compatibility All Author Mikhail Lavrov (DarkerLine) Setup: :cos(.1πcumSum(binomcdf(20,0→X :sin(.1πcumSum(binomcdf(20,0→Y :Plot1(xyLine,∟X,∟Y,(dot) :PlotsOff  Main code: :StorePic 1 (:ZoomSto) :-(B+D)/abs(D-B→Xmin :(A+C-124)/abs(C-A→Ymin :2/abs(D-B→ΔX :2/abs(C-A→ΔY :PlotsOn 1 :RecallPic 1 :StorePic 1 :PlotsOff (:ZoomRcl) :RecallPic 1  To use the routine, add the setup code to the beginning of your program. Then, to draw an ellipse, initialize (A,B) and (C,D) to be opposite corners of an imagined rectangle, in pixel coordinates, and run the main code of the routine. The ellipse will be drawn inside this rectangle (much like the functionality of the circle tool in Paint). Unlike built-in pixel commands, this routine doesn't require the pixels to be on-screen: you can use negative coordinates, and coordinates past the 62nd row and 94th column - of course, if you do, then the off-screen part of the ellipse won't be drawn. As for speed, the routine is far faster than the Circle( command. If you use Circle( with its undocumented fourth argument, that is a bit faster still - but doesn't allow you as much control over the shape of the ellipse as this routine does. This routine draws an ellipse given its pixel coordinates in two overall steps: 1. First, it calculates the window dimensions so that the unit circle (centered at the origin, with radius 1) will be stretched to the required pixel coordinates. 2. Next, it draws the unit circle. If the unit circle is stretched to fit in the rectangle from (A,B) to (C,D) then we know the following: • The vertical distance from A to C (in pixel rows) should be equivalent to the window distance 2 (from -1 to 1). This allows us to solve for ΔY. • The horizontal distance from B to D (in pixel columns) should also be equivalent to the window distance 2. This allows us to solve for ΔX. • The pixel most nearly corresponding to the midpoint between (A,B) and (C,D) should be equivalent to the point (0,0), the center of the circle. Given ΔX and ΔY, this allows us to solve for Xmin and Ymin. The exact math isn't significant, but it gives rise to the formulas you see in the routine. Note that by using the abs( command, we ensure that the order of the two points (A,B) and (C,D) isn't important: you can switch A and C, or B and D, and still get the same circle. The code for actually drawing the circle uses a look-up table for sine and cosine (which defines 20 points spaced around the circle). The table is calculated in the setup code, and then an xyLine plot is initialized, which will connect these 20 points when graphed. Now, to draw the unit circle, all that needs to be done is to enable the plot, using the PlotsOn command. This actually draws a 20-gon, rather than a circle, but the difference is imperceptible even on large circles. The rest of the code is necessary to preserve the graph screen as the window changes and Plot1 is enabled and disabled (which causes the screen to be cleared), using StorePic and RecallPic. Optionally, you can also preserve the window dimensions, using ZoomSto and ZoomRcl — this is useful if your program mixes pixel and point commands. The routine uses three fairly large variables to do its work: ∟X, ∟Y, and Pic1. ∟X and ∟Y need to be preserved from the setup code to whenever the routine is called; Pic1 is only used temporarily. It's a good idea to clean up all three by deleting them at the end of the program. {$strategyBegin}
Name Size Libraries? Compatibility Author
Bang Bang 3,670 No TI-83/84/+/SE Sean Weeks
Checkers 13,249 No TI-83/84/+/SE nitacku
Chess Pro 6,869 No TI-83/84/+/SE Francis Huang
Connect 4 4,000 No TI-83/84/+/SE SiCoDe
Dots 1,311 No TI-83/84/+/SE Travis Fischer
Lights Out 3,400 No TI-83/84/+/SE Scott Davis
Minesweeper 3,339 Yes TI-83+/84+/SE Fred Sparks
World Domination 10,000 No TI-83/84/+/SE Kerm Martian
World Empire 5,714 No TI-83/84/+/SE Arthur O'Dwyer
Xmove15 1,574 No TI-83/84/+/SE XprO

{$strategyEnd} {$rpgBegin}
Name Size Libraries? Compatibility Author
Castle Adventure 6,700 No TI-83/84/+/SE Arthur O'Dwyer
Metroid Pi 17,000 No TI-83/84/+/SE Harrierfalcon

{$rpgEnd} {$sportsBegin}
Name Size Libraries? Compatibility Author
Bowling 16,384 Yes TI-83+/84+/SE Nitacku
Slam Session 4,200 No TI-83/84/+/SE Jason Russell

{$sportsEnd} {$puzzleBegin}
Name Size Libraries? Compatibility Author
Brick Block 7,500 No TI-83/84/+/SE SiCoDe
Donut Quest 10,276 No TI-83/84/+/SE Mikhail Lavrov
DStar 4,800 No TI-83/84/+/SE Scott Davis
Lode Runner 3,000 No TI-83/84/+/SE SiCoDe
Sudoku 4,051 No TI-83/84/+/SE Harrierfalcon
Tower Of Hanoi 2,783 No TI-83/84/+/SE Martin Johansson

{$puzzleEnd} {$arcadeBegin}
Name Size Libraries? Compatibility Author
Blizz 1,863 No TI-83/84/+/SE Martin Johansson
Bomberman 4,969 No TI-83/84/+/SE Travis Fischer
Contra 10,000 No TI-83/84/+/SE Bryan Thomas
Dino Eggs 2,357 No TI-83/84/+/SE Alex Snyder
Frogger 1,232 No TI-83/84/+/SE SiCoDe
Nibbles Arcade 7,261 No TI-83/84/+/SE SiCoDe
Pipes 5,276 No TI-83/84/+/SE Sean Sartell
Snake Escape 1,120 No TI-83/84/+/SE Alex Snyder
Tetris 2,877 No TI-83/84/+/SE Nitacku
War 2,000 No TI-83/84/+/SE SiCoDe
Xsnake 1,468 No TI-83/84/+/SE XprO

{$arcadeEnd} {$casinoBegin}
Name Size Libraries? Compatibility Author
Commerce 5,300 No TI-83/84/+/SE Arthur O'Dwyer
Solitaire 3,993 No TI-83/84/+/SE Nitacku
Yahtzee 6,329 No TI-83/84/+/SE Brad Wentz

{$casinoEnd} {$miscellaneousBegin}
Name Size Libraries? Compatibility Author
Civilization Simulator 13,000 No TI-83/84/+/SE Kerm Martian
Office XE 21,076 No TI-83/84/+/SE Brad Wentz

{$miscellaneousEnd} One of the great things about working with TI Basic is that people are always developing new routines. This page is where you can display code for things that you think could be better than currently accepted routines. ## GetKey Routines This alternate routine is a size optimization of the usual movement routine used to move a character around the screen (9 bytes less than the regular routine). It is a replacement for the currently accepted movement routine. It was discovered by Darkstone Knight and Burr and implemented by Basickevin. :4→A :8→B :While 1 :getKey→K :1 :If K :" //one space// :Output(A,B,Ans :min(8,max(1,A+sum(Δlist(K={25,34→A :min(16,max(1,B+sum(Δlist(K={24,26→B :End  This is Basickevin's speed optimization of the same routine. It's about 15% faster, 25 bytes larger, and the variables are all under the finanace window. :4→PMT :1→FV :While 1 :getKey→PV :If PV :Output(PMT,FV," //one space// :min(8,max(1,PMT+sum(Δlist(PV={25,34→PMT :min(16,max(1,FV+sum(Δlist(PV={24,26→FV :Output(PMT,FV,1 :End  # References Routine Summary A simple instant messaging program. Inputs Str3 Outputs None Variables Used A, Str1, Str2, Str3 Calculator Compatibility TI-83/84/+/SE Author James Kanjo Download im.zip :"→Str1 :"→Str2 :GetCalc(A :e(A=π)+π(A≠π→A :Lbl M :ClrHome :Menu("IM","READ",R,"SEND",S,"QUIT",Q :Lbl S :Input "SEND MESSAGE: ",Str3 :If A=π:Str3→Str1 :If A=e:Str3→Str2 :Goto M :Lbl R :If A=e:Then :GetCalc(Str1 :Str1 :Else :GetCalc(Str2 :Str2 :End :Output(1,1,Ans :Pause :Goto M :Lbl Q  An "Instant Messaging" program, is a program that allows you to have an "instant" conversation with another person via a computer of some sort. With this program, you must connect two calculators via the calculator-calculator cable (it's about 22 centimetres long) before initiating the program on both calculators. Using this program means that you can be massive 22 centimetres away from a friend, and STILL be able to have conversations with them. Obviously this is a silly program, but its real purpose is to demonstrate the calculator's capacity to communicate with other calculators — and it's a great 'learning program'. Firstly, the program resets the Str1 and Str2 variables, which are used to later display "received messages", and executes the getcalc( command to retrieve variable A from the connected calculator. Then the program does something tricky; it checks to see if the variable A is equal to π (pi). If so, then it sets variable A to e. If A does not equal π, then π is stored to A. This is a complicated process which gives each calculator it's own identity — a vital part of cross-calculator programs. The menu then appears giving the user options to "receive" a message, "send" a message and to "quit". When the user tries to send a message, the program retrieves the user's input and temporarily stores it into Str3. The program then stores Str3 to variables Str1 or Str2, depending on the value of A. When the user goes to retrieve a message, depending on the value of A, it selectively retrieves Str1 or Str2 from the other calculator, which is the message that the other user has "sent". Of course, this isn't true instant messaging, but is at the least a simulation of it. Because the GetCalc( command retrieves data from another calculator, the other calculator needs to be idle to be able to send it. This program works because both calculators are always idle — in the menu, when typing a message and when reading a message. This routine uses Str1, Str2 and Str3, which you should clean up at the end of your program. While the contribute and conventions pages answer the general questions about how to create and edit pages, this page answers the specific questions about editing the homepages and any specialty pages (such as the command pages). If you have any questions that aren't mentioned, please leave a post in the forum or make a comment at the bottom of the page. # Uploading files There is now a tutorial to upload files on the site. # Recent News When you add some new content to the wiki, it is always recommended that you let the community know what you have done — especially if you made some significant edits. Each news item is stored on it's own page in the news category, including appropriate tags about the page; _news _83portal _68kportal _both-portals. These tags help us to automatically organise the news into categories. You can add news through the add news page. The news can be viewed through the 83 news, 68k news and all news pages. The portal home pages also automatically retrieve the 5 most recent news elements relative to their portal of the site. # New Members We love to encourage people to become members and contribute to improve the quality of the site. This is why we decided to compile a list of every member in the chronological order that they joined. From this page, we are able to show our appreciation with a warm welcome on the home pages to the newest members of the community. Unfortunately, this is a manual process — a member needs to regularly check the automatic list on the members page for any new members. If you notice that a new member has joined, please take it upon yourself to update the list. # Home Infobox On the home pages of the 83 and 68k portals, there is an infobox on the right-hand side of the page. This infobox provides some short, but useful information about some of the different sections of the site: how to get involved, what's happening in the forums, some interesting TI-Basic tidbits, the "top 10" rated programs, the featured article and the featured command. These things are not actually editable on the home pages themselves, but instead are automatically retrieved from other pages on the site — which is quite useful because it saves us from having to create duplicate copies of the same information. To manipulate these pages, just visit their appropriate links, and follow the instructions on those pages:  TI-83 Infobox: TI-68k Infobox: 83 Did You Know for Did you know… items. 83 Featured Command for the featured command. 83 Featured Article for the featured article. 68k Did You Know for Did you know… items. 68k Featured Command for the featured command. 68k Featured Article for the featured article. # Include Pages TI-Basic Developer utilizes the convenience of "include templates" throughout the site (a list of which can be found on the inc:overview page). These special pages are included as part of another page, and are used as templates for similar sections of code repeated amongst many pages (and hence, their name). For example, each command page has an infobox on the right-hand side giving specific details about the command. To get the template, we type in [[include inc:command, and then type in the values. This is much simpler and easier to use than typing out the whole infobox for each command, not to mention easier to understand and manage. For specific details on how to use all of the include templates, see the inc:overview page. # Privileges Required There are some pages on the site which can't be edited by ordinary members alone. This is because we believe that some pages just don't need editing, and don't need to risk being tampered with. In such cases that you believe one of these pages can be improved, then you have one of two options: 1. Start a discussion page in the forums; or 2. Send a private message to one of the administrators or moderators. Both options are effective, and so the decision is a matter of preference. If you want the community's opinion on the matter, post it in the forums. If you prefer to keep your conversations private, just send a private message: click on the avatar of the person, and click on the link saying "write private message". # Program Archives When people upload programs to the archives, it is up to us to do the hard work and integrate their program pages with the rest of the site. If you see any programs pending in the _to-do page, there are a few things you need to do: 1. Edit the page source — click on the "edit" button at the bottom of the page, then: • Paste the image URL (if any) in the |picture= section • Paste the program URL in the |downloadUrl= section • Copy the program file name in the |downloadName= section (for example, type in "Game.zip") 2. Click on the "save" button; 3. Remove the "_pending" tag — click on the "tag" button at the bottom of the page, and delete ONLY the "_pending" tag. You may want to see the full details of the tablet include. The featured commands are articles that represent the best TI-Basic Developer has to offer. A featured command meets all of the following requirements: • Well-Written — It is easy to read, flows smoothly, and does not have any spelling or grammatical errors. • Complete — It includes everything about the command, including theory, code examples, and screenshots, when appropriate. • References — If applicable, it lists the sources that were used in putting together the command. To nominate a command for being featured, add it to the list below. # Featured Command Candidates: • None so far… feel free to nominate one! # Featured Commands: The ListPages module does not work recursively. {$part1begin}

To add a command, move the current featured command from {$part2} to {$part3}, and add a new featured command to {$part2}. See the featured commands page to view the data on this page in a cosmetic format. {$part1end}
{$part2begin} The Menu( command displays a generic menu on the home screen, with up to seven options for the user to select from. If you need more than seven options, you can create another menu and then link to that menu. (more...) {$part2end}
{$part3begin} None yet… {$part3end}

{$part1-start} To add any new members on a new date, move the first date from {$part3} to {$part2}, and add a new date to {$part3}. The date format is day/month.

See the members page to view the data on this page in a cosmetic format.

{$part1-end} {$part2-start}

## 2006

 Sep 01 — TI-Basic Developer wiki is started by using the content from his TI-Basic Developer guide as the foundation for the wiki.
 Sep 02 —
 Sep 02 —
 Sep 11 —
 Sep 24 —
 Sep 24 —
 Sep 25 —
 Oct 01 —
 Oct 22 —
 Oct 25 —
 Oct 25 —
 Oct 25 —
 Nov 04 —
 Nov 06 —
 Dec 08 —

## 2007

 Jan 17 —
 Jan 18 —
 Feb 11 —
 Mar 21 —
 Mar 31 —
 Apr 11 —
 Apr 14 —
 Apr 16 —
 Apr 16 —
 May 15 —
 Jun 11 —
 Aug 20 —
 Sep 04 —
 Sep 04 —
 Oct 04 —
 Nov 04 —
 Nov 13 —
 Dec 12 —
 Dec 18 —
 Dec 24 —

## 2008

 Jan 16 —
 Jan 18 — brenns10 does not match any existing user name
 Jan 21 —
 Jan 26 —
 Jan 27 —
 Feb 03 —
 Feb 10 —
 Feb 12 —
 Feb 23 —
 Feb 28 —
 Mar 20 —
 Mar 23 — Recipito does not match any existing user name
 Mar 25 —
 Mar 25 —
 Mar 28 —
 Apr 10 —
 Apr 28 —
 May 04 —
 May 04 —
 May 07 —
 May 10 —
 May 26 —
 May 31 —
 Jun 06 —
 Jun 10 —
 Jun 10 —
 Jun 10 —
 Jun 10 —
 Jun 11 —
 Jun 11 —
 Jun 11 —
 Jun 12 —
 Jun 12 —
 Jun 12 — graphmastur does not match any existing user name
 Jun 12 —
 Jun 13 —
 Jun 13 —
 Jun 14 —
 Jun 18 —
 Jun 19 —
 Jun 21 —
 Jun 22 —
 Jun 25 —
 Jun 26 —
 Jun 28 —
 Jul 01 —
 Jul 02 —
 Jul 12 —
 Jul 18 —
 Aug 16 —
 Aug 16 —
 Aug 21 —
 Aug 25 —
 Aug 28 —
 Sep 07 —
 Sep 09 —
 Sep 17 —
 Sep 17 —
 Sep 23 —
 Sep 24 —
 Oct 02 —
 Oct 03 —
 Oct 04 —
 Oct 07 —
 Oct 24 — bxsciencer does not match any existing user name
 Oct 25 —
 Oct 26 —

{$part2-end} {$part3-start}

 Oct 27 —
 Nov 01 —
 Nov 09 — MasterDonut09 does not match any existing user name
 Nov 12 —
 Dec 14 —

{$part3-end} Random Numbers provide the essence of most games. They keep that element of chance alive. You cannot substitute for random numbers without someone who plays the game over and over again to figure out a pattern. Below we will start a discussion of random numbers.  Table of Contents # The Commands ## rand The rand command generates a random number between 0 and 1. It will display a decimal number longer than you can care for. It requires no arguments. BUT WAIT! There is a secret function to rand. First we must tell you something: the calculator doesn't produce random numbers. It's true. Calculators use pseudorandom number generators. It uses a complex formula to create the "random" numbers, mainly by a processing cycle. The secret to the random numbers is something called the seed. The seed is a number that is used to determine these random numbers. It is the starting number used, and an algorithm is used to generate pseudorandom numbers. One example method is the middle-square method, which starts with the seed, squares the number, and takes the half of that number, and repeats the cycle to generate numbers. More information about random vs. pseudorandom numbers can be found in this Khan Academy video: https://www.youtube.com/watch?t=59&v=GtOt7EBNEwQ The secret function to rand, is that you can set the seed using: :x→rand  where x equals the number. Set the seed to 1 on two different calculators and they put out the same sequence of numbers. Here's a trick. To set the seed to a random number, use this code: :rand→X :X→rand  rand can also be multiplied in order to get larger numbers. Just put a coefficient before rand. Also, you can generate a list of random numbers by doing this: :rand(x)  This will generate a random list with x number of elements. ## randBin( This command randBin(numtrials,prob) requires two arguments. numbtrials specifies the number of trials, and prob requires a number between 0 and 1. The manual's definition is this: Generates and displays a random real number from a specified Binomial distribution. ## randInt( Ah, yes, this one. It's the most common random number command. It requires two arguments, both very simple. The command is randInt(lower, upper). Lower specifies the minimum number possible. Upper specifies the maximum possible. For example, randInt(1,10) will generate a whole number between 1 and 10. Here is a simple program that uses randInt( :ClrHome :Disp "Think of your" :Disp "question and" :Disp "press enter." :Pause :randInt(0,2)→X :"Maybe" :If X=1 :"Yes" :If not(X) :"No" :Disp Ans  In this program, the user thinks of a question that he or she would ask a magic eight ball. It calculates a random integer between 0 and 2 (0, 1, or 2). It makes "Maybe" the default answer. The program then tests the random number under the conditions to make the string, "Maybe", change to "Yes", "No", or remain the same. ## randM( This may be not as well-known as the others. This command will generate a random matrix. The command syntax is randM(rows,columns). Rows stands for the number of rows in the matrix, columns for the number of columns. The numbers in the matrix are the random part. ## randNorm( This command will generate a number, with given randNorm(µ,σ), within the range µ±3σ. The command uses a normal distribution based on the 68-95-99.7 empirical rule. When the third argument is given, it will generate a list of that many elements. # Putting it Together Let's make a program that will use the random commands. The program will be a game where it is you against the computer. You take turns where one player thinks of a number between 1 and 10, and the other player must guess as close as possible. The AI will use random numbers as his guess. :rand→X :X→rand :ClrHome :SetUpEditior L₁ :{30,30}→L₁ :Delvar A :Repeat L₁(A)<0 :A(A≠2)+1→A  Okay, first we reset the seed. Then, we set up the game by storing each player's health into a list and deleting A, the turn. The loop starts and is set to end when a player's health reaches below zero. The next thing that happens is that the player number turn switches between 1 and 2, with human being 2 and AI being 1. :If A=2 :Then :Repeat N>0 and N≤10 :Input "Your Number?_",N :int(N)→N :End :randBin(10,N/10) :End  This is what happens when it is your turn. You must input a number where the calculator makes sure your number isn't less than 1 or greater than 10. It also ensures an integer number. The calculator uses a formulated guess which gives it a higher probability of guessing right (I know… cheap). :If A=1 :Then :Input "Guess?_",N :abs(int(N))→N :randInt(1,10) :End  This is what happens when it is the calculator's turn. The calculator first randomly chooses a number, and then you are asked to give a guess. The calculator will not check for boundaries, but it will check for decimals. :ClrHome :L₁(A)-abs(N-Ans)→L₁(A) :End :ClrHome :"You"+sub("Win!Lose",3(L₁(1)<0)+1,4)  This is the final part of the code where it takes the difference of the guesses and subtracts that from the turn player's opponent. When the game ends, it displays a message at the end. :rand→X :X→rand :ClrHome :SetUpEditior L₁ :{30,30}→L₁ :Delvar A :Repeat L₁(A)<0 :A(A≠2)+1→A :If A=2 :Then :Repeat N>0 and N≤10 :Input "Your Number?_",N :int(N)→N :End :randBin(10,N/10) :End :If A=1 :Then :Input "Guess?_",N :abs(int(N))→N :randInt(1,10) :End :ClrHome :L₁(A)-abs(N-Ans)→L₁(A) :End :ClrHome :"You"+sub("Win!Lose",3(L₁(1)<0)+1,4)  That sums up random numbers, and the last section of this chapter. We hope you learned a lot.  Home Screen Variable Types User Input Calculator Linking Controlling Flow Code Examples Test Yourself An algorithm refers to your method of solving a problem. Algorithmic optimization, then, relies on choosing the best method to solve a particular problem. Although we could choose a complex problem to illustrate algorithmic optimization, a simpler problem is equally sufficient in demonstrating the process that you go through. For our example problem, imagine that you want to reverse the characters in a string: if the string is "HELLO", you want it to be "OLLEH". This obviously is a routine that would only really be useful if you are writing a text editor, and are providing different ways for the user to manipulate the text (search, replace, insert, copy, etc.). Knowing what the routine needs to do, the straightforward approach to writing it is to use another string to store the reversed string, and then concatenating the respective substring to the end of the string while looping over the original string backwards using a For( loop. Here is what the code would look like: :" " :For(I,length(Str1),1,-1 :Ans+sub(Str1,I,1 :End :sub(Ans,2,length(Ans)-1→Str1  As you can see, we are using the Ans variable to hold our temporary string of reversed characters. You should also note that we initialize it to one space before entering the For( loop. This is because TI-Basic does not allow empty strings — it will actually return a ERR:DOMAIN if you try to concatenate or manipulate the string. Although this approach is efficient, there are still other ways to write the routine. One possibility is using recursion — the program calling itself. This is basically replicating what the For( loop was doing in the previous routine, except this time we don't have an additional variable to keep track of the string position. Instead we are using the actual length of the string itself, and then subtracting the length of the temporary string from that. In order for this to work, however, we need to add an additional character to the end of our string. This is because our temporary string is initialized to a space, so we need to offset this character to get the complete reversed string. If we don't add the extra character, our reversed string will be missing the first character from the original string — we would get "LLEH" instead of "OLLEH". The actual code for the routine is: :Ans+sub(Str1,length(Str1)-length(Ans),1 :If length(Ans)<length(Str1 :prgmREVERSTR :sub(Ans,2,length(Ans)-1→Str1  Note that in order to run the routine, you need to initialize Ans on the home screen to a string with one character: a space is the character we like to use, but it can be a question mark, a letter, a number, or whatever you want. Also note that the program name must be the actual name of the program on your calculator; we just called our program REVERSTR because we like names that are descriptive. When you try out this routine, you should notice that it works just as effectively as the first routine for short or medium length strings. However, if you try using a long string, the routine might not actually complete, but instead the calculator will run out of memory — giving you a ERR:MEMORY error. Each time a program call is made, the calculator puts it on a stack and it takes sixteen bytes to keep track of each program call. Because this stack is placed in RAM, whether you are able to completely reverse the string or not depends on how much free RAM you have on your calculator. The other problem with using this routine is that it has to be its own stand-alone program. This is because the code has to go at the beginning of the program, in order for the recursion to work correctly. Of course, a four line program isn't necessarily bad, but it can be a nuisance having to remember an additional program to use your program. Using recursion to reverse a string is obviously not going to work for us when you factor in the memory for the program calls and the additional program, so that means we should stick to using a For( loop. Now we need to think about how else we could go about reversing a string. How about instead of looping over the string backwards and appending the respective substring to the end of the string, we loop forwards and append the substring to the beginning of the string? Does that sound like it would work any better? Well, let's try it. We are still going to use the temporary string stored in Ans like we did with the other two routines, except this time the original string is stored to Ans instead of just a dummy character. We then loop through each character starting from the beginning to the end, adding it to the beginning of the string as we build up the reversed string. Here is what the code would look like: :Str1 :For(I,1,length(Ans)-1 :sub(Ans,2I,1)+Ans :End :sub(Ans,1,I→Str1  Since adding to the beginning of the string alters the index, we must take that into account — this is where the 2I in the formula comes from. It adds the 2nd character the first time, the 4th character (which was originally the 3rd) next, the 6th character (originally the 4th) after that, and so on. Comparing the size of the last routine to the size of the first two routines, the code is now smaller, and so coming up with a better algorithm has resulted in a better program. Of course, this required some creative thinking on our part, but it was well worth the effort. [[include inc:routine |picture=@@ |summary=@@ |input=@@ |output=@@ |variable=@@ |compatibility=@@ |author=@@ |authors=@@ |url=@@ |download=@@ ]] ## |picture= If the image is embedded on the same page, then only the full name of the image is to be written here. Otherwise, simply paste the full URL of the image. ## |summary= Just type in a brief description of the routine ## |input= Enter all inputs required for the routine to work, and include a brief description of what they are ## |output= Enter all outputs the routine generates, and include a brief description of what they are ## |variable= Just give a brief description of all variables the routine uses ## |compatibility= Enter the calculators compatible with a syntax similar to the example used for all calculators: TI-83/84/+/SE ## |author= Enter the author of the routine, if only one person created it ## |authors= Enter a list of authors of the routine, if more than one person created it ## |url= Enter a URL to any relevant or related websites, followed by a space, and what you want to display. For example: |url=http://www.unitedti.org Routine's Derivative ## |download= Enter the URL to a downloadable version of the routine, followed by a space, and what you want to display. For example: |url=http://tibasicdev.wikidot.com/routine.zip routine.zip [[include inc:program |picture=@@ |summary=@@ |size=@@ |libraries=@@ |compatibility=@@ |author=@@ |download=@@ ]] ## |picture= If the image is embedded on the same page, then only the full name of the image is to be written here. Otherwise, simply paste the full URL of the image. ## |summary= Just type in a brief description of the program ## |size= Just type in a brief description of the program size ## |libraries= Just type in a brief description of what libraries are required to run the program ## |compatibility= Enter the calculators compatible with a syntax similar to the example used for all calculators: TI-83/84/+/SE ## |author= Enter the name of the author of the program ## |download= Type in the URL to the program in accordance with the wiki syntax, and any other details if required A | B | D | E | I | L | M | N | O | R | S | T | U | V | W | Z In the Error Conditions section on a command page, descriptions will be given of the errors that can result when using a command. These do not include errors that can occur with virtually any command, such as ERR:ARGUMENT or ERR:SYNTAX. However, if one of these errors is triggered in an unusual way, it will be listed. Be aware that certain errors don't occur when graphing or using one of the commands DrawF, DrawInv, Tangent(, or Shade(. Instead, the graph point is skipped and treated as an undefined value. Tangent( is a minor exception, actually: if there's an error at the tangent point, it will be treated normally. The errors that are ignored in graphs are: There are are also several error messages that don't actually occur (as far as anyone knows) from normal use of the calculator — however, the messages are stored in the OS along with the normal messages. It's conceivable that an assembly program, especially an official TI application, would use these error messages for its own purposes. These messages are ERR:SOLVER, ERR:SCALE, ERR:NO MODE, ERR:LENGTH, and ERR:APPLICATION. # A ## ARCHIVED • You have attempted to use, edit, or delete an archived variable. For example, dim(L1) is an error if L1 is archived. • Use UnArchive variable name to unarchive the variable before using it. For lists, SetUpEditor is recommended instead since it does the same thing, but works on the TI-83 (which has no archive) as well, and does not crash when the list is undefined. • There is no way to archive or unarchive programs using pure Basic, although several assembly utilities are available for doing so. • When you attempt to edit a archived Matrix,List,Variable, or program, the option 2:GOTO doesn't show up. • Use Unarchive or the memory manager to unarchive a variable,matrix,list, program, etc. ## ARCHIVE FULL • You have attempted to archive a variable and there is not enough space in archive to receive it. • Sometimes, if the calculator displays a message from memory management saying "Garbage Collect?", choosing the option No gives this error. ## ARGUMENT • A function or instruction does not have the correct number of arguments. See the appropriate command page. • A function or instruction that can have any number of arguments has 256 or more. • In general, if a function has more than one non-SYNTAX error in it, this is the error that will be generated first (if it applies, of course). • Generally, on graphing calculators and such, most functions ex: randi( require that you use commas to make a list. # B ## BAD ADDRESS • You have attempted to send or receive an application and an error (e.g., electrical interference) has occurred in the transmission. ## BAD GUESS • With the solve( function, the equation solver, or an operation from the CALC menu, your guess wasn't within the lower and upper bound, or else the function is undefined at that point. Change the guess. ## BOUND • In a CALC operation or with Select(, you defined Left Bound > Right Bound. • In fMin(, fMax(, solve(, or the equation solver, the lower bound must be less than the upper bound. ## BREAK • You pressed the [ON] key to break execution of a program, to halt a DRAW instruction, or to stop evaluation of an expression. # D ## DATA TYPE • You entered a value or variable that is the wrong data type. • For a function (including implied multiplication) or an instruction, you entered an argument that is an invalid data type, such as a complex number where a real number is required. • In an editor, you entered a type that is not allowed, such as a matrix entered as an element in the stat list editor. • You attempted to store an incorrect data type, such as a matrix to a list. • You attempted to divide matrices, which should be done by matrix inversion and multiplication instead. • This error is not returned when graphing (see the note at the top of the page). ## DATE • Only on the TI-84+ or TI-84+ SE, this error occurs when an invalid date is entered. • Below the error menu, an explanation of what's wrong is given: e.g., "Invalid day for month selected." ## DIM MISMATCH • You attempted to perform an operation that references more than one list or matrix, but the dimensions do not match. • In most cases, the dimensions are required to be equal, with the following exceptions: • When multiplying two matrices, the number of columns of the first must match the number of rows of the second. • When using augment( to combine two matrices, only the number of rows must match. • With the List►matr( command, the lists don't have to match sizes - shorter lists will be padded with zeroes. ## DIVIDE BY 0 • You attempted to divide by zero. • You attempted a linear regression on data that fit a vertical line. • This error is not returned when graphing (see the note at the top of the page). ## DOMAIN • You specified an argument to a function or instruction outside the valid range. This error is not returned during graphing. The TI-83+ allows for undefined values on a graph. • You attempted a logarithmic or power regression with a negative X or an exponential or power regression with a negative Y. • You attempted to compute ΣPrn( or ΣInt( with pmt2 < pmt1. • You've assigned a value to n (the sequential graph variable), nMin or nMax that isn't an integer, or that is less than 0. • This error is not returned when graphing (see the note at the top of the page). ## DUPLICATE • You attempted to create a duplicate group name. • You attempted to create a duplicate program using AsmComp(. ## Duplicate Name • A variable you attempted to transmit cannot be transmitted because a variable with that name already exists in the receiving unit. • Also appears when you unpack a group and a variable in the group is already defined. In both cases, it will give you several options for correcting the error, including Omit, Rename, and Overwrite. # E ## EXPIRED • You have attempted to run a Flash application with a limited trial period which has expired. ## Error in Xmit • The TI-83+ was unable to transmit an item. Check to see that the cable is firmly connected to both units and that the receiving unit is in receive mode. • You pressed [ON] to break during transmission. • You attempted to perform a backup from a TI-82 to a TI-83+. • You attempted to transfer data (other than L1 through L6) from a TI-83+ to a TI-82. • You attempted to transfer L1 through L6 from a TI-83+ to a TI-82 without using 5:Lists to TI-82 on the LINK SEND menu. • You attempted to use SendOS with no other calculator connected. • When this error occurs, the option 2:Goto doesn't show up, but will redirect you to the LINK screen instead of the main screen. # I ## ID NOT FOUND • This error occurs when the SendID command is executed, but the proper calculator ID cannot be found. • When this error occurs, the option 2:Goto does not show up. ## ILLEGAL NEST • You attempted to use an invalid function in an argument to a function. • This happens when using seq( in the expression for seq(, fnInt( within the first argument of fnInt(, expr( inside the string argument of expr(, or summationsigma within the argument for Σ(. ## INCREMENT • The increment in seq( is 0 or has the wrong sign. • The increment in a For( loop is 0. • This error is not returned when graphing (see the note at the top of the page). ## INVALID • You attempted to reference a variable or use a function where it is not valid. For example, Yn cannot reference Y, Xmin, ΔX, or TblStart. • You attempted to reference a variable or function that was transferred from the TI-82 and is not valid for the TI-83+. For example, you may have transferred UnN1 to the TI-83+ from the TI-82 and then tried to reference it. • In Seq mode, you attempted to graph a phase plot (uvAxes, uwAxes, or vwAxes) without defining both equations of the phase plot. • In Seq mode, you attempted to graph a recursive sequence without having input the correct number of initial conditions. • In Seq mode, you attempted to reference terms other than (n-1) or (n-2). • You attempted to designate a graph style that is invalid within the current graph mode. • You attempted to use Select( without having selected (turned on) at least one xyLine or scatter plot. • You attempted to use certain functions (e.g. If, Then, Else) outside a program. ## INVALID DIM • You tried to access an element past the end of a list or matrix (there is an exception: it's allowed to store to the element one past the end of a list, adding the element). • You specified dimensions for an argument that are not appropriate for the operation. • You specified a list dimension as something other than an integer between 1 and 999. • You specified a matrix dimension as something other than an integer between 1 and 99. • You attempted to invert a matrix that is not square. ## ITERATIONS • The solve( function or the equation solver has exceeded the maximum number of permitted iterations. Examine a graph of the function. If the equation has a solution, change the bounds, or the initial guess, or both. • irr( has exceeded the maximum number of permitted iterations. • When computing I%, the maximum number of iterations was exceeded. # L ## LABEL • The label in the Goto instruction is not defined with a Lbl instruction in the program. • When this error occurs, the option 2:Goto doesn't show up. # M ## MEMORY • Memory is insufficient to perform the instruction or function. You must delete items from memory before executing the instruction or function. • You might also want to try archiving some variables,matrixes,lists,etc if you have nothing in RAM that you don't need. • Recursive problems return this error; for example, graphing the equation Y1=Y1. (but Y1=X, Y2=Y1, for example, will NOT cause an error.) • Branching out of an If:Then, For(, While, or Repeat loop with a Goto will waste memory until the program finishes running, because the End statement that terminates the loop is never reached. Unless a program is very large, this is one of the likeliest causes of ERR:MEMORY. Refer to memory-leaks. ## MemoryFull • You are unable to transmit an item because the receiving unit’s available memory is insufficient. You may skip the item or exit receive mode. • During a memory backup, the receiving unit’s available memory is insufficient to receive all items in the sending unit’s memory. A message indicates the number of bytes the sending unit must delete to do the memory backup. Delete items and try again. • You may also try to archive some variables to free up some memory that you do not plan to transmit. ## MODE • You attempted to store to a window variable in another graphing mode or to perform an instruction while in the wrong mode; for example, DrawInv in a graphing mode other than Func. # N ## NO SIGN CHNG • The solve( function or the equation solver did not detect a sign change. • You attempted to compute I% when FV, (N*PMT), and PV all share the same sign. • You attempted to compute irr( when CFList and CFO share the same sign. ## NONREAL ANS • In Real mode, the result of a calculation yielded a complex result. • This error is not returned when graphing (see the note at the top of the page). • This error can appear if you use a negative number for some operations, such as ln # O ## OVERFLOW • You attempted to enter, or you have calculated, a number that is beyond the range of the calculator (-1E100 to 1E100, non-inclusive). • Sometimes you can fix this error by re-ordering operations. For example, 60!*30!/20! will return an overflow error, but 60!/20!*30! will not. • This error is not returned when graphing (see the note at the top of the page). # R ## RESERVED # S ## SINGULAR MAT • A singular matrix (determinant = 0) is not valid as the argument for -1. • A regression generated a singular matrix (determinant = 0) because it could not find a solution, or a solution does not exist. • This error is not returned when graphing (see the note at the top of the page). ## SINGULARTY • The expression in the solve( function or the equation solver contains a singularity (a point at which the function is not defined). Examine a graph of the function. If the equation has a solution, change the bounds or the initial guess or both. • Although the correct spelling is "singularity", the error message shown has "singularty" on all calculators and OS versions. ## STAT • You attempted a stat calculation with lists that are not appropriate. • Statistical analyses must have at least two data points. • Med-Med must have at least three points in each partition. • When you use a frequency list, its elements must be at least 0. • (Xmax - Xmin) / Xscl must equal 47 for a histogram. ## STAT PLOT • You attempted to display a graph when a stat plot that uses an undefined list is turned on. • To fix this error, use the command PlotsOff to turn off plots when you're using the graph screen. ## SYNTAX • The command contains a syntax error. Look for misplaced functions, arguments, parentheses, or commas. See the appropriate command page. • This error will also occur in place of a DATA TYPE error if the variable type in question is a variable name (with seq(, solve(, For(, and other commands) • The command was attempting to get expr( of a non-value string, i.e., trying to evaluate a space, equals sign, etc. # T ## TOL NOT MET • You requested a tolerance to which the algorithm cannot return an accurate result. # U ## UNDEFINED • You referenced a variable that is not currently defined. This error doesn't occur with number variables (A-Z,θ), which have a default value of 0. • Lists, matrices,strings,pictures, and GDBs have to be stored to first, in order to be used. • Most system variables always have a value, so this error doesn't apply to them. • However, statistical variables are undefined except for those used by the last relevant command. • Undefined equation variables (such as Parametric and Polar variables) return ERR:INVALID instead of ERR:UNDEFINED. # V ## VALIDATION • Electrical interference caused a link to fail or this calculator is not authorized to run the application. ## VARIABLE • You have tried to archive a variable that cannot be archived or you have have tried to unarchive an application or group. • Variables that cannot be archived include: • The number variables R, T, X, Y, and θ (because they are used for graphing) • The list ∟RESID (because it's reserved for residuals from regression models) • System variables (including statistical variables, finance variables, equations, plots, and window variables) • The AppIdList. ## VERSION • You have attempted to receive an incompatible variable version from another calculator. # W ## WINDOW RANGE • A problem exists with the window variables. • You defined Xmin>Xmax or Ymin>Ymax. • Xmin and Xmax (or Ymin and Ymax) are equal or so close that numerical precision can't allow for enough values between them. • The values for θmin, θmax, and θstep create an empty or never-ending loop for θ. • The values for Tmin, Tmax, and Tstep create an empty or never-ending loop for T. • When this error occurs, the option 2:Goto doesn't show up. # Z ## ZOOM • A point or a line, instead of a box, is defined in ZBox. • A ZOOM operation returned a math error. • When this error occurs, the option 2:Goto doesn't show up. # Other ## ? • An unknown error has occurred. This page is a guide to the template pages. Command Summary {$summary}

Command Syntax

{$syntax} Menu Location {$location}

This command requires a calculator with Flash memory (that is, it will not work on a TI-92).
Calculator Compatibility

This command requires a calculator with AMS version 2.{$ams2xx} or higher (it will also work on any TI-89 Titanium or Voyage 200 calculator) Calculator Compatibility This command requires a TI-89 Titanium or Voyage 200 calculator with AMS version 3.{$ams3xx} or higher.

{$size} This article is currently in development. You can help TI-Basic Developer by . I will get around to finishing this, probably during the Summer Holidays. ~ James Kanjo Multiplayer is where two or more people play a game together at the same time. Although you can create AI opponents for a player to play against, AI does not offer as much fun compared to playing against other human opponents — you can have the players work together, compete against each other, and even one player manage the other players. Multiplayer games are generally divided into two categories: the players share a single calculator, and the players each play on their own calculator connected together with a link cable (either I/O or USB). # Single-Calculator Multiplayer Multiplayer games on one calculator generally fall into two categories: real-time and turn-based. Real-time is where the game action is constantly changing, not stopping for the player input. Some classic examples of real-time games are Galaxian and Pong. Turn-based is where each player is allowed to make a move, and the game action only changes after each player has moved. Some classic examples of turn-based games are Battleship and Scorched Earth. Making real-time games involves using the getKey command, except you can't wait for a key to be pressed. The general form is something along the lines of: While <game not done> getKey->K If K=<player 1 key>:Then // player 1 action End If K=<player 2 key>:Then // player 2 action End <Update rest of game> End  As you can see, the player action only occurs when a player has pressed a particular key; otherwise the game just continues on like regular, with the main game loop being repeated over and over again. There are some problems with making real-time games, however. The first, and foremost, problem is that TI-Basic is rather slow with user input. If you do anything remotely time-intensive, such as displaying lots of graphics or complex variable manipulation, then there will be some lag-time between when a player presses a key and when the calculator gets around to processing it. Although there's not really much you can do about this, you can make sure your game is as optimized as possible (especially breaking the more time-intensive parts into their own subprograms). The second problem is that the calculator only keeps track of the last key pressed since the last time getKey was executed, so that means only one player can have their input read and processed each time through the game loop. In addition, if you enter a large block of code for the player, it will take a while before the other players have a chance to do anything. Related to the second problem, the third problem with making real-time games is that unlike the other keys, the arrow and DEL keys can actually be held down, which will cause them to keep being repeated until they are unpressed. The effectively disables the other keys from being able to be pressed. There is no viable way to get around this problem, except asking the players to not press those keys. The fourth problem is that the keypad is quite small, and having two or more people try to share the calculator can be rather difficult. The best way to work around this problem is choosing keys for each player that are a good distance away from each other. When choosing keys you should also keep in mind the calculator screen — if somebody has to press keys that make it difficult to see the screen, then you should choose different keys. Because making real-time games is not very practical, a better alternative is turn-based games: you hand the calculator from player to player, allowing each each player to move one at a time. These games are much easier to program: you simply use a variable to keep track of whose turn it is, increment the variable after each player's turn, and when everybody has completed their turn, you reset the variable. The only real downfall of turn-based games is that they can be slow because you have to wait until the other players are done before you can move. # Multi-Calculator Multiplayer So I guess you're wondering how to program a multi-calculator multiplayer experience into one of your games. One of the first things you will need to do is familiarize yourself with the GetCalc( command. Basically, it retrieves a specified variable from another calculator and stores it to that variable on yours. Creating multiplayer programs over two calculators is a much less simple process as it is to make single-calculator multiplayer programs. However, doing so could be the main selling point of your program and would certainly be worth the effort. You will notice that in each of our examples we tend to transfer lists, which we recommend you do too. Whilst it is possible to transfer a variety of real variables, it is much faster to transfer a list of numbers than a number of real variables. There are two general ways to programming multi-calculator programs; one screen processing and two screen processing. The one screen processing method is simply making a program use the statistics from another calculator, and the whole multiplayer experience is processed on that calculator. The two screen processing method is much more complex, where we can share the multiplayer processing across two calculators by using a "turn-by-turn" interface. ## Core When it comes to multi-calculator multiplayer games, it is absolutely necessary to give each calculator its own identity. As both calculators are running the exact same program, we need a way to be able to determine one calculator as "Calculator A" and the other calculator as "Calculator B". This makes it possible for both calculators to know what data to send and receive. For example, if both calculators were "Calculator A", then both calculators would be doing exactly the same thing, or keep trying to receive the same variable from each other in an endless loop This is code determines which assigns each calculator with a unique identity: :GetCalc(A :e(A=π)+π(A≠π→A  How it works is that the calculator gets the variable A from the other calculator, and checks whether it equals π (pi). If A equals π, then e is stored to A; however, if A does not equal π, then π is stored to A. Here is a table to demonstrate the results: Calculator A Calculator B A = π A = e A = 3.141592654 A = 2.718281828 The calculator can therefore identify itself like this: :If A=π:Disp "I'M CALC A :If A=e:Disp "I'M CALC B  If we use a not( routine to make Calculator A = 1 and Calculator B = 0 instead, then we are unable to determine whether a link has been initiated. Simply explained, because variable A is more likely to equal zero than any other number, Calculator A may accidentally assume Calculator B has initiated the multi-calculator sequence. Variable A is not likely to ever equal π (or e), which is why it's useful as a "connection initiated" checker for the calculator. The beauty of the core code is that it doesn't matter which player executes the core code first, both calculators will be able to give themselves a unique identity, be able to distinguish which calculator they are and be able to see whether the other calculator is initiated yet. ## One Screen If you are looking to save space and valuable time, this is the multiplayer for you. This method has the sending calculator in a power-saving state the whole time while the receiving calculator does all of the hard work such as processing and animation. First off, we put in the core multiplayer code to determine which calculator is which. Then, Calculator B will retrieve the opponent's statistics for battling. Because the program uses the same variables on every calculator, we need to find a way to store Calculator A's statistics onto Calculator B without overwriting Calculator B's statistics. Surprisingly, this is not as hard as it seems: :GetCalc(A :e(A=π)+π(A≠π→A :If A=π:Then :∟STATS→L₁ :Disp "SENDING DATA...","PRESS ENTER WHEN :Pause "FINISHED :End  Now that each calculator has created its unique identity, and Calculator A has stored its statistics to L₁, we can finally make Calculator B receive Calculator A's statistics and process all of the data: :If A=e:Then :GetCalc(L₁ <interactive code> :End  After this, write the rest as though this was a single-calculator multiplayer game, where you're statistics are in ∟STATS and your opponent's statistics are in L₁. Here is a side-by-side comparison on how the program runs: Calculator A Calculator B ## Two Screens Here we show you a turn by turn based method of a battle game. Like with all multi-calculator multiplayer programs, we first provide the program with the core. This time, however, we will first reset variables A and F. Then we will add code for which stores each calculator's statistical data to its individually named list. Calculator B is then instructed to go elsewhere in the program (note that Goto is within an If-Then loop): :DelVarADelVar FGetCalc(A :e(A=π)+π(A≠π→A :If A=π:Then :∟STATS→L₁ :Else :∟STATS→L₂ :Goto W :End  Because this is turn by turn battle game, we need to repeat the battle code until the battle is finished. We will make variable F determine this. Also, we want Calculator A to be able to attack first, so we shall put the code for attacking as the first thing in the Repeat loop. This is where it starts to get a bit sticky. First we delete variable B, which is going to determine what command the user has chosen (whether it be a kind of attack, or to run away). :Repeat F :DelVar BMenu("CHOOSE ATTACK","ATTACK A",A,"ATTACK B",B,"RUN AWAY",R :Lbl A:1→B:Goto S :Lbl B:2→B:Goto S :Lbl R:‾1→B :Lbl S:1→θ  So when the user selects an option from the menu, a number is stored to B and 1 is stored to θ. Theta tells the receiving calculator that it the sending calculator is not ready yet. Then we create a second menu. This is to give the receiving calculator a chance to receive certain variables. That process is almost instant, and so the user then presses ENTER. θ is erased and 1 is stored to S, just before the "animation" program starts. S simply tells the animation program that it has just sent the attack. :Menu("SENDING ATTACK","READY?",SA :Lbl SA:1→S :DelVar θprgmθANIMAT  The animation program is shared by both the attacker and the attacked. The program makes particular animation depending on whether variable S is equal to one. If S=1, then this program will only display the opponent getting hurt. If S=0, then this program will display YOU getting hurt, calculate how much HP you have left, and if you died, sets variable F to zero. By using the subprogram "prgmθANIMAT", it means we don't need to worry about memory leaks or program changes. Now we have the receiving code. You will notice that Lbl W is the first line here. This is so that Calculator B can jump straight here on the first move. Because this label is within a repeat loop, and the Goto came from an If-Then section, there are no memory leaks. The first thing we do is make the program wait until the sending calculator has issued a move. If the game is over (F=1), then this process stops, and the program exits the "Repeat F" loop. If the game is not over, and the opponent issued a move, then the calculator receives the opponent's updated statistics. :Lbl W:Disp "WAITING... :DelVar BRepeat B or F :GetCalc(B :GetCalc(F :End :If not(F:Then :If A=e:GetCalc(L₁ :If A=π:GetCalc(L₂  At the moment upon entering the loop, we know that the opponent's θ equals 1. In this loop, we clear our θ variable and then retrieve the opponent's θ. Because of the nature of GetCalc(, we can not receive variables whilst the other calculator is processing. Remember that as soon as the other calculator exits the "SENDING ATTACK…" menu, the animation subprogram starts. Using this knowledge, if we delete θ and then retrieve θ whilst the opponent is in the "SENDING ATTACK…" menu, θ will equal 1 (and hence the loop is repeated). But when the opponent starts the animation process, we will be unable to retrieve θ, and so θ will equal what it all ready was, zero (hence we exit the loop). :Repeat not(θ :DelVar θGetCalc(θ :End :DelVar SprgmθANIMAT :End :End  This code is rather remarkable because it makes it possible to start the animation on both calculators, at the same time, automatically. You don't need to go messing about with "both users press ENTER at the same time" routines, only one user needs to press ENTER and both calculators begin — a foolproof technique. If, after the animation process, the battle is not yet over, then the program continues into attack mode again (at the start of the "Repeat F" loop). Now we need a routine which restores the statistics to the ∟STATS list and says who won after the battle is over! This is the easiest part of the routine. If the player's health points do not equal zero, then that player won — otherwise the other player won. :L₁ :If A=e:L₂ :Ans→∟STATS :If Ans(6:Then :Pause "YOU WON! :Else :Pause "YOU LOST! :End  There are a couple of things that you need to be aware of for this routine to be work: 1. When the "SENDING ATTACK" menu pops up, you must wait for a second for the attack to actually send before pressing ENTER; 2. Variable A must NEVER equal π during the program, (obviously with the except of the multi-calculator code itself). If it does, and a different calculator starts this routine before the other one, then the link process will fail. To prevent the second problem from ever happening, you should reset variable A at the start of your program, and never use this variable throughout the program. This whole routine is certainly complex, but it does work, and works pretty well too. Here is a side-by-side comparison of how the program runs. For reference, here is a table showing the values: Calculator A Calculator B ∟STATS(1)=2 ∟STATS(1)=5 ∟STATS(2)=2 ∟STATS(2)=5 ∟STATS(3)=2 ∟STATS(3)=5 ∟STATS(4)=2 ∟STATS(4)=5 ∟STATS(6)=2 ∟STATS(6)=5 Calculator A Calculator B # Final Notes Whilst the abilities of the GetCalc( command make it harder to create multi-calculator programs, it certainly is not impossible. You just need to think extra hard and create very clever workarounds to its boundaries. If you have any questions or comments about these routines please ask in the discussion area for this page. # References • James Kanjo came up with the "Multi-Calculator Core" code in his IM program, and also came up with the "turn by turn battle" code, including the function to make one calculator respond to another calculator's ENTER keypress Forum 101  Category name Threads Posts Last post Announcements 16 53 by 10 Nov 2017 21:38Jump! Community IntroductionsIntroduce yourself to the community 214 1140 by 14 Nov 2017 00:52Jump! Site FeedbackQuestions and commentary about the site 188 2026 by 06 Nov 2017 13:01Jump! Wiki Page DiscussionsQuestions about certain wiki pages 919 3776 by 20 Nov 2017 22:25Jump! General Discussion  Category name Threads Posts Last post Open TopicYou can talk about anything 326 2368 by 10 Nov 2017 10:12Jump! Humor & JokesPost a funny picture or joke 30 330 by 04 Nov 2017 23:50Jump! Politics & ReligionArguments and rants welcome 10 225 by 26 Mar 2016 19:46Jump! Tech SupportGet help with your technology questions 259 1866 by 23 Nov 2017 00:42Jump! Programming & Design  Category name Threads Posts Last post TI-83/84 ProgrammingDiscuss TI-83/84 topics 1528 12634 by 22 Nov 2017 07:59Jump! 68k ProgrammingDiscuss 68k topics 91 495 by 05 Nov 2017 01:25Jump! TI-Nspire ProgrammingDiscuss TI-Nspire topics 196 878 by 13 Nov 2017 15:43Jump! Assembly ProgrammingDiscuss Assembly topics 170 1209 by 07 Nov 2017 21:02Jump! Computers & Web DevelopmentDiscuss computers and web development 74 508 by Thel 'Vadamee (guest)17 May 2017 20:38Jump! Projects & Contests  Category name Threads Posts Last post Your ProjectsShare your projects 163 2035 by 21 Nov 2017 16:07Jump! Project IdeasShare your project ideas 78 957 by 17 Nov 2017 01:21Jump! Program ChallengesSeeing who can create the best program... 62 1154 by 29 Sep 2017 19:14Jump! Name That CommandTest your command knowledge 4 466 by 08 Apr 2016 04:20Jump! Optimize MeTest your optimization prowess 37 473 by 26 Oct 2017 21:32Jump! BrainteasersTry to stump others 11 522 by 04 Sep 2017 00:43Jump! Show hidden RSS: New threads | New posts  This article is part of the coding stage of the development cycle. Code conventions are a set of guidelines for writing programs, primarily focusing on the structure and appearance of the code. Although code conventions are generally subjective and informal, just the individual preferences of each programmer developed over time, there are several common conventions that most programmers follow and are considered to constitute good programming practice. Following code conventions not only makes your code consistent, helping to make it easier to read and understand, but also eliminates a lot of the difficulty in maintaining it. Code conventions are also important in group projects, where multiple people are working together and everybody needs to be on the same page. # Naming The general convention for naming programs, subprograms, labels, and custom lists is to choose a name that tells you what it is (in the case of programs and subprograms) or that relates to how it is used (in the case of labels and lists). For example, if your program is a Minesweeper clone, then a good program name is something like MINES. If your MINES program has a subprogram, start it with θ or Z so that it appears at the bottom of the program list. If you have a highscore function built-in to your game, then you should use a custom list that is related to your program's name (i.e., LMINE would make sense for the MINES game mentioned above). In the case of a label name, you should make it mnemonic — Lbl UP would be an appropriate choice for the code that moves the screen up. # Formatting The general convention for formatting code is to place related statements together on the same line. This is most applicable with variable declarations, If-Then conditionals, and short loops, although you can certainly put whatever statements that you want. The way you get multiple statements on the same line is by separating each one with a colon, which is also used to denote the beginning of each new line. The program editor on the calculator allows sixteen characters per line, so if the statements are wider than that, they will cause the line to wrap around to the next line (and however many more lines are needed). # Structure The general convention for structuring code is to use a loop, except for those situations where using a loop is impractical; in those cases, using a Goto is the preferred convention. When deciding which loop to use, you need to look at what its functionality will be. If you want the loop to be executed a set number of times, then you should use a For( loop. If you want the code inside of the loop to be executed at least once, then you should use a Repeat loop. The While loop is very similar to the Repeat loop, so the way to decide when to use either one is by thinking of the loop condition. If the loop is going to keep running as long as the condition is true, then you should use a While loop. If the loop is going to run until the condition is true, then you should use a Repeat loop. # Variables The general convention for using variables is to use the most appropriate variable whenever possible. There are several different kinds of variables available, including reals, lists, matrices, and strings, and they each have their own time and place. Reals are used for keeping track of one value, and because they are both small and fast, you should use them before using other variables. Lists are used for keeping track of multiple values, and because they can be created, you should use them for saving highscores and other important data. Matrices are used for keeping track of two-dimensional values, which means you should use them for making maps on the screen. Strings are used for keeping track of characters, which means you should use them when you want to display text on the screen. # Sample Program The following sample program is a modified form of the program on the movement page. The main things you should notice are the real variables grouped together on the first line and the use of the Repeat loops for the code structure. PROGRAM:MOVEMENT :4→A:8→B :Repeat K=105 :Output(A,Ans,"X :Repeat Ans:getKey→K:End :Output(A,B," " :A+(Ans=34)-(Ans=25 :Ans+8(not(Ans)-(Ans=9→A :B+(K=26)-(K=24 :Ans+16(not(Ans)-(Ans=17→B :End  [[include inc:command |picture=@@ |summary=@@ |syntax=@@ |location=@@ |compatibility=@@ |size=@@ ]] ## |picture= If the image is embedded on the same page, then only the full name of the image is to be written here. Otherwise, simply paste the full URL of the image. ## |summary= Just type in a brief description of the command ## |syntax= Enter the general syntax of the command ## |location= Give step by step instructions of how to paste the command into the program. Separate each step with a new line, beginning each line with a # and a space following it. For example: # Step One # Step Two ## |compatibility= Enter the calculators compatible with a syntax similar to the example used for all calculators: TI-83/84/+/SE ## |size= Just enter the number of bytes the token takes up, and the word byte or bytes. For example, |size=1 byte or |size=2 bytes [[include inc:68k-command |picture=@@ |summary=@@ |syntax=@@ |size=@@ |hex=@@ ]] In general, omitting all the variables for a section is the way to go if you don't want the section to be displayed. The exception is "calculator compatibility" - omitting the variables for that section will display the default message (compatible with all calculators). ## |picture= If the image is embedded on the same page, then only the full name of the image is to be written here. Otherwise, simply paste the full URL of the image. ## |summary= Just type in a brief description of the command. ## |syntax= Enter the general syntax of the command. ## Menu Location This section depends on the type of menu location: Simple key press |simplekey=(key) |command=(command)  Key press varies across models |ti89key=(key on TI-89 or TI-89 Titanium) |ti92key=(key on TI-92, TI-92+, or Voyage 200) |command=(command)  Popup menu |popuptitle1=(popup menu title) |popupkey1=(the key for that menu) |popuptitle2=(submenu title - OPTIONAL) |popupkey2=(key for that submenu - OPTIONAL) |popuptitle3=(sub-submenu title - EVEN MORE OPTIONAL) |popupkey3=(key for that sub-submen - ALSO OPTIONAL) |laststepkey=(key to finally paste the command) |command=(command)  Toolbar menu |toolbar=(toolbar name: program editor, home screen, or graph screen) |tooloption=(toolbar option name - e.g. F2 - I/O) |toolmenu=(toolbar submenu - OPTIONAL) |toolmenukey=(key for the submenu - OPTIONAL) |laststepkey=(key to paste the command) |command=(command)  ## Compatibility If the command works on all calculators, nothing needs to be done. Otherwise add one of the following: • |flashrom=1 if the command requires Flash ROM • |ams2xx=yy if the command requires AMS version 2.yy • |ams3xx=yy if the command requires AMS version 3.yy (on a TI-89 Titanium, or Voyage 200) Only one option can be applied (and they are exclusive of each other), otherwise unpredictable results may occur. ## Size If you wish to include the token size section, you need to make the size tag equal to the number of bytes it takes up, plus the word "byte" (or "bytes" if it takes up more than one byte). For example, |size=1 byte or |size=3 bytes To enter details of token size, specify the hex code for the command itself (hex=0x##) as well as any of the tags that apply to that command: |EXT_INSTR_TAG=1, |EXT_CMD_TAG=1, and |END_TAG=1 for the respective tags. Program Summary {$summary}

Program Size

{$size} Uses Libraries? {$libraries}

Calculator Compatibility

{$compatibility} Author {$author}

Download

{$download} Routine Summary {$summary}

Inputs

{$input} Outputs {$output}

Variables Used

{$variable} Calculator Compatibility {$compatibility}

Author

{$author} Authors {$authors}

URL: [{$url}] Download [{$download}]

Welcome to the TI|BD Sandbox! A Sandbox is basically a place where you can trial pages/features/whatevers to see whether they will work, before you actually release it to its appropriate section on the site.

Start a new page:

All pages currently under the "Sandbox" category:

The ListPages module does not work recursively.

Command Summary

{$summary} Command Syntax {$syntax}

Menu Location

{$location} {$compatibility}

{size} This page includes all pages within the "SK" category. The ListPages module does not work recursively. This page includes all pages within the "Nav" category. The ListPages module does not work recursively. This page includes all pages within the "Forum" category. The ListPages module does not work recursively. This page includes all pages within the "Admin" category. The ListPages module does not work recursively. This page includes all pages within the "System" category. The ListPages module does not work recursively. This page includes all pages under the "Template" category. The ListPages module does not work recursively. This is the page with a list of deleted pages. The ListPages module does not work recursively. This page contains a list of all pages withing the "inc:" template. See the GUI version here. The ListPages module does not work recursively. krazyness suggested that it would be a good idea to implement a site logo, to replace the current header of the TI|BD wiki. He took the liberty to design and produce the logo. There was much discussions relating to the design of site logo (which can be found here) which led to modifications and new versions, each an improvement from the last. The people who have actually produced the possible logos for the wiki are krazyness, James Kanjo, DarkerLine, and Battlesquid.  Table of Contents # Original Header: This was the original header which krazyness set out to replace. # Version 1: krazyness Produced the original logo design for the site (his own design). # Version 2: krazyness Manipulated the first version to render the letters "A" in "Basic" and "V" in "Developer" in a higher quality. # Version 3: krazyness Rendered the image based on the colours of the wiki, #172028 and #E7E9DC. # Versions 4-9: James Kanjo Uses 'very sophisticated photo editing software' (MS Word) to improve the image quality of the logo. Shrunk the height to 63 pixels, because he misread the discussion on the logo, and thought it said to be 63 pixels high instead of 67 pixels high: Variation with the text gradient dark at the bottom and light at the top: Variation with different colours which are relative to the site: Changed the lighting and shadows of version 5. Changed the height of the image to 68 pixels, as that was thought to be the necessary height of the image to fit properly. Added a gradient in the background which fades to the colour #172028 over a length of 32 pixels: Changed the height of version 6 to 68 pixels for the same reason mentioned in version 7. Adjusted lighting. Added a gradient in the background which fades to the colour #172028 over a length of 32 pixels: Modified the gradient in the text of version 8 to focus the light in the middle and darkness on the outsides: # Version 10: Version 10A: James Kanjo Realised that the height of the logo should in fact be 67 pixels in height. Made the text look more 'polished' by making it brighter in the middle of the text. Shrunk the main header text. Added subtitle "The TI-Basic Information Repository". Changed the gradient to fade into the colour #172028 over a length of 200 pixels rather than 32. Version 10B: James Kanjo Increased the height in pixels to be 69 pixels high, because the browser Internet Explorer showed a pixel row that should have been hidden, and so that there is no black pixel row at the bottom of the logo on forum pages. The difference is negligable to the human eye, but it is definitely noticeable when placed in the header. Version 10C: DarkerLine First try at making a 68k version of the logo. Version 10D: Battlesquid An attempt towards creating an Nspire header. Traces of blue are on the logo's letters, so that is yet to be resolved. Version 10E: Battlesquid Made a successful attempt towards creating an Nspire logo to go with the agreed upon theme. Note: Downloading programs is only necessary if you are looking for programs to use on your calculator. If you are just interested in TI-Basic programming, please skip this page and move on to the Variables page. Before downloading any programs, you should create a folder to store the programs. Where you decide to store this folder is up to you, but the two most common places are the desktop or hard drive (typically the C: drive). Storing folders on the desktop is very convenient, allowing you to quickly access a program without having to hunt and search for it, but the desktop can easily become cluttered with programs and other files. Within the folder itself, you should give each program its own folder and also create a downloads folder to contain the .zip files that the programs are contained in when you download them (see below for more information about .zip files). Although you could put each .zip file with its respective program, it is better to separate them in case you want to delete the program folder but still keep the program for later use. When naming the program folders, you should use the full program name and include the version number of the program. This is important because there might be several similar programs — for example, snake games are a dime a dozen — and there might be more than one version of the program. Having the version number in the program folder name allows you to easily determine if you have the latest version of the program. # What to Download While there are several calculator sites on the Internet that have programs, the sites with the largest program archives are ticalc.org, calcg.org, and unitedti.org. Each of these websites has many different kinds of programs available, including math, science, utilities, graphics, and games, and you can generally find whatever it is that you are looking for. There is a wide range of quality among the programs, however. Most programs are hit and miss — you don't know if the program will be any good until you download and try it out. There are some simple indicators that you can use to gauge a program's quality: the number of downloads, the rating (if available), the reviews (if available), and the screenshots (if available). None of these is really foolproof, however, because they can be manipulated by the program author. Generally speaking, assembly programs are of higher quality than TI-Basic programs. This is due to the fact that assembly programs are programmed in the calculator's own machine language, which is more difficult to learn, but allows for much greater speed and functionality. Consequently, most people programming in assembly are fairly decent programmers, and thus most assembly programs that you will find are good quality. TI-Basic, on the other hand, is simple enough that almost anybody can make programs using it, so there are lots of programs available; the large sites listed above are literally flooded with TI-Basic programs. This is good if you like variety, but most of the programs are of subpar quality, featuring crappy coding, gameplay, and graphics. If you are looking for quality TI-Basic programs, your best bet is to check out the programs on the showcases page. # Opening a Zip File When downloading a program, it will typically be packaged inside of a .zip file. A .zip file is used to group one or more individual files together for easier downloading, while compressing them to reduce their size. An average program, for example, includes the main program itself, some subprograms, screenshots of the program, and a readme document describing the program and how to use it. In order to use the contents of a .zip file, you need to "unzip" it using a zip utility program. There are several different zip utility programs available, but which program you are able to use depends on your operating system. The most popular zip program for Windows is WinZip, while the most popular zip program for MacOS is StuffIt Expander. After you download a zip program, you need to run the executable (i.e., the .exe file) to install it. Once you have your zip program installed, you can begin unzipping your programs. This is actually quite simple, and just involves right clicking a .zip file, arrowing down to the zip program that you installed, and clicking on an extract option. There will generally be a few options for where you can extract the .zip file: the same location as the .zip file, to a specific folder, or to anywhere you want. Of course, since you have your programs folder, you should unzip your programs to that folder. # Using a Program Although there are usually several files inside of a .zip file, calculator files are the only ones that you can actually use and send to your calculator. There are several different calculator file types available, including programs, groups, images, lists, matrices, strings, Flash applications, and even operating systems, but not all of those are available on every calculator. Each TI calculator has their own set of file extensions that they work with: the pattern that file extensions follow is the first two characters are the calculator, and the third character is the file type. The regular calculators (such as the TI-83) use the calculator number for the first two characters, while the plus calculators (such as the TI-83+) use the first number and a letter. For example, a file extension of .8xp means that the file is for a TI-83+ or TI-84+, and it is a program. Besides having the calculator files for the program, you should also read through the readme document that came with the .zip file (if there is one). Although most TI-Basic programs do not require any additional programs to run, some do require assembly libraries (such as xLIB). The majority of assembly programs require a shell, such as MirageOS or Ion. You should check to see what requirements the program has, and download the appropriate files. Once you have all of the required files to use the program, you can send them to your calculator. This requires a TI-Basic editor (either Graph Link or TI Connect) and a calculator-to-computer link cable (either TI-Graph Link or USB Link). If you are using Graph Link, you just open it up, click the Send menu option, select your files, and click Send. Using TI Connect is similar, except you drag and drop the files to the desired location. If you don't have a calculator-to-computer link cable, another option is to type the files into your calculator manually. You just open a TI-Basic editor (or use SourceCoder), find the program files in the appropriate directory, and then type in the individual commands. Depending on the size of a program, this can take anywhere from a couple minutes to several hours. This option does not work with assembly programs, however, since they are written in machine code and compiled. The game loop is the fundamental structure of most games. It repeats throughout the game, managing all necessary information and user input. Of course, the game loop will be different depending on the type of game. In a shooting game, it might loop continuously, tracking player movement if there is any, and frequently moving enemies and updating scores and such. In a chess game, it might loop once for every turn, waiting for user moves and updating the positions of pieces only when one is moved, or it might loop every second if a timer is implemented. In general, however, it will usually look like this: while the player has not won: update game information (for example, score or turn count) accept user action update game status (for example, locations of pieces/units/player) display relevant information  There are four main types of loops used in programs. There are For( loops, While loops, Repeat loops, and Goto loops. The first three are the most commonly used whereas the Goto not so much. You probably already read about loops in the previous chapter, but this discusses the fundamentals of each loop in detail and displays the application of such things when referring to game building. # While Loops This loop is the most basic loop. What you do is put a condition after it, and while that condition is true, the loop will continue to run between the While and its End until the condition becomes false. So, when the calculator encounters a While, it tests the condition after it and depending on whether it is true or not, the calculator will either execute the loop or skip it. If it executes the loop, it will continue to do so until the condition after While becomes false. Let us consider this code: :3→A :While A<10 :A+1→A :Disp A+1 :End :Disp "Finished"  This code, of course, initially stores 3 into A. Then, it encounters the While loop. What the program then does is tests the A<10. If it is 1 (or true), then it will execute the next commands. If it is 0 (or false), then it will skip to the End and continue from there. In this case, 3<10 is true, so it begins the loop by executing the following commands. A increases by 1, and then it displays one more than that value. So, it displays 5, but A is 4. When the program reaches the End, it then tests A<10 again. If it is true, then it will execute the commands again. If it is false, it will continue after the End. So, since 4<10, it will do the loop commands again. So it now displays 6. It will continue to do this until A is equal to or greater than 10. So, once A becomes 10, the program will display "Finished!". That is the essence of loops: repeating a group of commands while or until a condition becomes true, or when something specific occurs. While loops are good for elimination games where while player is still alive, his turn commences. If the player is eliminated, then it would skip the loop. Another reason for a While loop is as a sub loop where an action from the user determines the usage of the second loop. If the action doesn't involve the loop, then the loop can be skipped. # Repeat Loops The Repeat loop is almost the same as the While loop, but there is a difference. First of all, the repeat loop will continue to loop until the condition after it is true. So, if the condition is not true, then it will continue to loop until that condition becomes true. Another difference is that when the calculator encounters a Repeat, it doesn't scan the condition. It will automatically start the loop and test the condition when it reaches the appropriate end. When the calculator reaches a Repeat, it cannot be skipped. Consider the following code: Note: The difference between a While loop and a Repeat loop is that the While can be skipped depending on the condition. A Repeat loop is always executed regardless of initial condition. :15→A :Repeat A=15 :A=15→A :Disp A :A+2→A :End :Disp "Finished"  This code firsts stores 15 into A. Now, it begins the loop. Since it is a Repeat loop, the loop is automatically executed even though the condition is true. Since A is 15, the Boolean logic becomes 1 and is stored into A. The first display is 1. The program then adds two to A. When it reaches the End, the loop goes back to the condition and tests it. It will continue through the same cycle until the A becomes 15. When that happens, the program displays "Finished". Repeat loops are typically used as the main, or base, loop of the program or action. The reason for this is so the loop becomes automatically executed rather than being skipped. Also, the mentality of a game loop is to continue gameplay until the person dies/loses. With this mentality, the condition is easily depicted as the situation when the player loses making the loop end at that instance. # For( Loops This loop is not like the others, and it is a little more complex. This loop requires 3 arguments with one optional argument. When writing a For( loop, you use this syntax: For(variable,start,stop,[increment]) If increment is not given, the calculator assumes it is one What the loop does is it first stores the start number into the variable. Then, it runs through the commands until it reaches End. When End is reached, the calculator loops to the For, adds increment to the variable value, and runs through the commands again. The loop continues to run until stop is reached. When that number is reached, then the calculator will proceed executing commands after the End. Consider this code: :For(A,2,6) :Disp A :End  This code starts the For( loop by giving A the value of 2. After it displays the two, the program adds one to A and displays again. It continues to add one until it hits 6. When that happens, the program runs through Disp one more time and ends the loop. This type of loop can become incredibly useful in games. If the user makes an action where multiple things must be accomplished but of similar origin, a For( loop can be used. This loop can also be used when there is a certain number of turns being played. You could set up the loop as For(T,1,10) for a 10 turn game and put the code between the For( and its appropriate End. As you practice with this loop, you will understand exactly how useful it can become. # Goto Loops This is probably the least common loop used in the TI-Basic community. What you do is you place a Label somewhere and later in the program put a Goto leading to the label for the use of repeating a set of commands. This type of loop requires no arguments or conditions, but it must be exited with some sort of other Goto. Although this is a relatively fast type of loop (if the Label is near the top), the positioning of the Goto could lead to some problems. The problem with goto is the event of Memory Leaks in which the calculator loses memory within the program and eventually terminates due to lack of RAM. This occurs when you have a Goto within a loop or condition that leaps to a label outside of that loop. The calculator uses memory every time it encounters a loop in order to remember that it needs to find an End somewhere. The problem is, when a Goto is used to jump out of the loop, that memory is lost because the calculator never found End. So, although useful in some cases, Goto loops are not recommended for primary game loops. Goto and Lbl have a different purpose really. They can instead be used to locate various loops for game functionality. If you reach a condition that needs to be jumped backwards to another loop, a Goto Lbl combo can be used to easily jump back to the loop. Although dangerous, these Goto's do have a use, just be careful when placing them within loops. # Infinite Loops An infinite loop is a loop that continues forever. The most common infinite loop is While 1. Since the condition can never be 0, the loop never ends. These loops in a game are not as useful as a terminating loop, but they can be utilized along with Goto to produce a game with a function that repeats several times regardless of status. Loops like this can be used when the player can't lose, only quit. In such situations, an infinite loop can be used and a Goto can determine when to leave (careful of memory leaks). These loops are typically replaced with a While loop that has a condition for when the player quits, but nonetheless, this loop can be used only sparingly. # Application So, how can these loops be applied to making a game? Well, for BASIC games, loops are often needed for repetitive or continued tasks. A loop can be put somewhere near the beginning, and that loop can continue to run until the player loses. The main loop is the Repeat loop. It is typically used as the base for games. The conditional used after the loop is typically like this: :Repeat (player dies/loses) or (getKey value)=45 code code code :End  This way, when the player loses, the loop ends, or when he clicks Clear, the loop ends. The content of code code code could be anything really, but it typically follows a pattern found in many basic games. The code usually starts with updating the game stats and output. This is used mainly for turn based games as most games will update the information at the end of the code. Then, the program should ask or give opportunity for user input, accept it, and take action upon it. After that, the game should update output and other game stats or allow an AI to activate. This is a list of the basic game types and what types of loops can be used to accomplish these actions. ## Action An action game is one where the playing field is constantly changing whether the player does something or not, and depending on the input, other things on the field react to the action of the user. These types of games can be quite challenging because of the constant update. The reason is because of the additional coding put under the same loop as the input selection, usually getKey. This slows down the system's ability to accept user input. So, let's say you wanted to make a game where if X became 0, you lost, or if you hit getKey, the game ended. X is 5 when you win. Also, there are multiple things occurring even if the user takes no action. You can use the following code :Repeat X=0 or X=5 or Ans=45 :Output(A,B,"_") :min(8,max(1,A+sum(ΔList(Ans={25,34}))))→A :min(16,max(1,B+sum(ΔList(K={24,26}))))→B :Output(A,Ans,"O") other activity coding :getKey→K :End :ClrHome :Disp "You"+sub("LoseWin!",4(X=5)+1,4)  So, we are using a Repeat loop with some conditionals after it. The conditionals represent when the game ends: when you lose (X=0), when you win (X=5), and when you quit (press Clear). The program loops through the game until one of the conditions is met. The next thing the program does is update user action info. Depending on which arrow key the player clicked, the program will move in that direction (remember from Movement?). Next, you would put other action after the update, but only put a small amount of coding, or else the least possible. The more code you put in other activity coding, the slower the game will be, and nobody likes a slow game. Finally, the game should ask for user input. Now, it may seem weird to ask for input at the end, but it is a very useful technique. The reason the input is at the end is to use Ans in the loop conditional which makes the game run a little faster. Anywhere you can get speed makes an action game better, so try to follow this general outline. As you get more experienced, you will begin to find other alternatives to this loop as the type of game changes, but for now, this outline will help you make basic games. ## Strategy/Turned Based A strategy or turn based game is one that waits for the user input before the calculator makes any further action. In this type of game, speed is not normally as important because it is usually a thinking type game. The coding for a strategy game works in a way as described at the beginning of the article. You would need separate scores for each player. If it were an elimination type game, then a While loop can be used within a Repeat loop to indicate player turns. The loop pattern would be sort of like this: Repeat one player is left Update player turn by one or reset to one at max Update player information output While player is alive or Clear Ask for input act upon input update game info update output End extra stuff End  This works by repeating the loop until one player is left and updating all player info according to previous outputs. The While loop is used for the player input. However, if the player is eliminated, then the While loop will be skipped. It will then ask for input and update that player's info accordingly. So, putting this code to action, let us say that you are building a Risk game. You can have a Repeat loop backbone the whole game and use nested While loops for player action. Here is an example (although a rather poor one) for a Risk game where L1 is the board of 42 spaces where iPart is the number of troops and fPart is who is occupying the space, T is the player turn, and K is the getKey. :Repeat not(variance(10fPart(L₁))) :T(T≠4)+1→T show stats :While max(T=10fPart(L₁)) or K=22 :Repeat Ans :getKey→K :End Update info Update Output :End :End  So, this code has L1 as the whole board. Since the fPart is the occupant of the territory, then when all of the territories have the same occupant, the variance( will be 0, and since not( is used, the equation becomes 1 when the answer is 0. So, the loop ends when all territories are occupied by the same person. The While loop won't even execute if there is not a single square with occupant T. That represents that player being eliminated. So, the loop goes back to the beginning. The turns are updated for every pass, and then T=4, the turn number is set back to 1. ## Limited Turns A game with limited turns ends when a counter reaches a certain number. There are a couple of ways you can do this. You can use a Repeat loop with turn number T. When T, which is updated every loop, reaches a certain number specified in the Repeat conditional, the loop will end. Or, you can use the For( loop. The For( loop automatically updates a variable and ends when the stop is reached. So, you can set up a code like this: :For(T,1,(last turn)) Output turn number Update conditions Secondary loop Ask for User input Update action  Pretty much, all you are doing is setting up a turn keeper and using one of the previous loop examples to run the main function of the game. Turn based games is really just an added addition to the other loops. # Conclusion This wraps up the Game Loop tutorial. This is just the basics of making a game. In making a game, the loop only represents the backbone of the program. What lies within a loop is the meat, and that is what makes the game function. The next section deals with data types which will introduce to you the various ways we can manipulate numbers to accomplish jobs. Once you have been writing programs for a while, you may realize that you can't accomplish everything by entering numbers and strings. In a program such as a game, you often need to accept arbitrary keypresses. That's where getKey comes in. # How It Works getKey is the 7th entry in I/O under the PRGM menu. It returns a number corresponding to the key pressed by the user. But if you put it into a program by itself, it doesn't seem to do much - it immediately gives you a "Done". This is because getKey checks for a key only in the fraction of a second when it executes, and then returns a 0 if it doesn't find one. Commonly, it will be inside some kind of loop so that the program doesn't proceed until a key is actually pressed. :Repeat K :getKey→K :End  In this case, getKey is repeatedly stored in K until a key is pressed, at which time getKey returns a positive value, which is accessible in K after the loop exits. The number returned by getKey is formed from the row and column the key is in on the calculator. The row is from 1 (Y= to GRAPH) to 10 (ON to ENTER), and the column starts from 1 and goes left to right. The arrows left, up, and right are in row 2, and down is in row 3. 101 (ON) is not actually returnable by getKey because pressing ON in a program stops the execution of the program # Uses Obviously, there are many ways to use key presses in a program. You can let users select a choice without having to enter a number or go through a menu. Or you can let users input a command such as CLEAR. However, be sure to let the user know what each key actually does, for the sake of usability. Or, in a game, key presses can be used to control a character. For example, the arrow keys move a spaceship, and 2nd fires the laser. In a turn-based game the above loop method is useful, as you can create a loop for the turns and accept a user action on each turn. But in a real-time game you would probably not want to use a loop around getKey, so that the game isn't interrupted by waiting for a key. Instead, you can let the program run continuously and check once for a key once per some (short) interval of time, so user commands are still accepted correctly. For more, see the next section. The reason this works is that even if the key press doesn't line up with getKey exactly, if a key is pressed while the calculator is doing something by itself (the progress bar is going in the top right corner, for example), it carries over to the next getKey. Alternatively, a held-down key will register on the first getKey while it is being held down, and the arrow keys and Del will continue to register with further getKeys until they are released. By changing the loop around a getKey, only a certain key can be accepted. :Repeat K=105 :getKey→K :End  This will ignore all key presses until 105 (ENTER) is pressed. In this case, it is probably better to use Pause. But in general, getKey is a very useful tool for accepting a wide range of user input. Getting Additional Help Most of the members of this wiki can be found on the forum, so you can post there with questions and get help with whatever you are working on or trying to learn. In order to post on the forum, however, you need to create an account. This is an easy process, and should take no more than a couple minutes. It is the goal of this site to eventually cover all information on TI-Basic programming for the TI-83 series of calculators. However, an excess of information can be overwhelming, so this page gives a suggested reading order (as well as necessary tidbits) so you don't get lost. There are two alternatives for those who have just ventured into programming for these calculators. While you might want to just jump in, we have a tutorial that explains the basics of TI-Basic and another that answers basic TI-Basic questions. The first, the TI-Basic Starter Kit, teaches TI-Basic without assuming any previous programming experience. In fact, the very first section explains how to create your first program. After reading this tutorial carefully, you should be more than ready to handle the rest of this site. The second tutorial is the TI-Basic FAQ. As the name suggests, it is an attempt to answer the common TI-Basic questions that people ask. Many of the questions are related to each other, so it is recommended that you read through the whole list. If you have any questions that aren't mentioned on the list, or an answer doesn't help, please leave a post in the forums and somebody will try to help you. # Further Reading At this point, you should be familiar with more than a few TI-Basic commands. It might be a good idea to just jump into the command index and click on commands that sound interesting — you can really improve your TI-Basic knowledge that way. Or, select a category from the Commands menu in the top navigation, and read about commands in a more general way. Looking at code examples is also a good way to learn. Games and Programs are a good place to find such example code. See the Routines page for several short routines to get simple things done in the best possible way. Use the glossary whenever you come across a term you're not familiar with. If it's not there or the entry doesn't help, drop a note in the forums and (usually within a day) helpful people will explain it and hopefully improve the glossary as well, so no one else has the same trouble. The pages in the Reference section of the top menu are probably not ones you'd read for fun. Take a look at them at any time to see what they're all about, and then check back when you need to know more. # Writing a Program Of course, the best way to learn these topics is to come up with a project of yourself (check the project-ideas page if you have no ideas), and go through the steps as you're doing it: 1. Look at Planning when you're thinking about how to approach the problem. 2. Consider Commenting Code and Code Conventions when you're writing it. 3. If bugs arise (and they most likely will), see the section on Debugging. 4. When the program works, add Setup and Cleanup to it, and check the sections on Usability and Portability. 5. If the program is too slow (and maybe even when it's not), see Optimization and Code Timings for ways to improve it. 6. Finally, see Releasing Your Program for how to earn TI-Basic programming fame by making the program public. These are listed in the Design section of the side navigation menu. # Advanced Topics The Techniques section in the side navigation menu discusses some advanced issues in TI-83 programming. You should probably have a good grasp of programming before venturing into these pages, but they are worth reading. Give them a glance to see how much you can understand. Each technique is mostly a stand-alone page. Here are the relative difficulties of the pages: ### Easy • Friendly Windows — makes using the graph screen commands much easier. • Piecewise Expressions — very important to programmers. • Saving Games — almost as easy as just storing to a variable. • Highscores — an extension of saving, using a string for names and a list for scores. • Animation — adds some visual pop or pizazz to your programs. ### Intermediate • Validation — how to ensure user input satisfies your requirements. • Making Maps — how you store the contents of the screen to a variable. • Movement in Maps — adds user interaction to programs. • Custom Text Input — useful when you want to get input on the graph screen. • Custom Menus — allows the user to choose among different options. ### Hard • Graphics — different ways to make graphics and sprites. • Compression — if you wanted, you could get into some heavy theory with this. • Self-Modifying Code — code that changes itself while it is executing. • Subprograms — calling one program from another, including external and internal programs. • Assembly — you can make much better programs, but they are larger and more complicated. # Review 1. What are the advantages of TI-Basic compared to assembly? 2. Where do you edit programs on the calculator? 3. What characters are allowed for a program name? 4. How do you get an ERR:BREAK error? 5. How do you get the letter variables A through Z? 6. How do you store a value to a variable? 7. Describe what input and output are, and give an example of each. 8. What is the value of this conditional — A/B and C≥D — when A=52, B=3, C=0, and D=2? 9. How many options are allowed in a Menu( command? 10. Describe how a For( loop works, and give an example. # Programming 1. Write a program that displays your name and age centered on the screen, underneath one another. 2. Modify the STATES program below by adding a couple more options for U.S. states. 3. Write a program that computes the sum of the first N positive integers, for a user-supplied value of N. 4. Modify the NUMBERS program below to only display odd numbers. PROGRAM:STATES :Menu("U.S. STATES","FL",FL,"NY",NY) :Lbl FL :Disp "FL" :Stop :Lbl NY :Disp "NY"  PROGRAM:NUMBERS :For(X,-20,20) :Disp X :For(Y,1,20) :End :End  1. TI-Basic is the built-in programming language on all of TI's graphing calculators. 2. When making programs, there is a general order that you follow: you create the program, then you edit the program, and finally you execute the program. 3. A variable is a place where a data can be stored globally. Each of the letters A through Z (as well as the θ symbol, which is Greek and pronounced "theta") is a variable that can hold a number. 4. Input happens when a program lets the person running it press a key or type something in, so that it can do something with that. Output happens when a program displays results on the screen. 5. Control structures are instructions that explain which steps the calculator should follow, and in which order. 6. The Goto command tells the calculator to jump to another point (more specifically, a corresponding Lbl) in the program, and continue running it from there. 7. Loops are a type of control structure used to repeat a block of code several times. There are two kinds of loops: a loop that repeats until a condition is satisfied and a loop that repeats a fixed number of times. # Commands Introduced This is the end of the first part of the tutorial! To review, here is a sample program that includes the ideas you've learned about in the previous few pages: the traditional guessing game. It will ask you to guess a number between 1 and 1000 in 10 guesses; every time you guess, it will tell you if the number is lower or higher. # The Program :ClrHome :randInt(1,1000)→N :Disp "Guess a number" :For(I,1,10) :Input "Guess?",G :If N=G:Then :Disp "You've got it!","Guesses:",I :Pause :Stop :Else :If N>G:Then :Disp "Higher..." :Else :Disp "Lower..." :End :End :End :Disp "You lose!","The number was:",N  # An Explanation :ClrHome :randInt(1,1000)→N :Disp "Guess a number"  The program starts off with a bit of a curve ball: two commands, ClrHome and randInt(, that we haven't really covered yet. ClrHome clears the home screen, and randInt( gives a random number. These will be covered later on, in the second part of this tutorial, so don't worry if you don't quite understand them. In any case, the command randInt(1,1000)→N makes N a random number between 1 and 1000. Finally, we display "Guess a number" to start off the game. :For(I,1,10) :Input "Guess?",G ... :End  To give the player 10 guesses, we use a For( loop that goes from 1 to 10. The variable I is the number of the guess we're on. The Input command simply asks for a guess, and stores it to G. Remember that N is the number the player's trying to guess. :If N=G:Then :Disp "You've got it!","Guesses:",I :Pause :Stop :Else :If N>G:Then :Disp "Higher..." :Else :Disp "Lower..." :End :End  This is the most complicated part of the code. To make the nesting of the If commands clearer, it's been indented above, although it wouldn't be on a calculator. The first check is if N=G: if the guess is correct. If it is, we go to the Then part of the first If. Here we display "You've got it!", and how many guesses it took. We pause the program with Pause, so that the user can read the info we'll provide. Then with the Stop command, we exit the program. If the guess wasn't correct, we go to the Else part of the first If. Now we need to display a hint - higher or lower. This is accomplished by the second If statement. If N>G, it goes to the Then part, and displays "Higher…" Otherwise, it goes to the Else part, and displays "Lower…" There is no Stop here, so the program continues from there, and does the next cycle of the loop. :Disp "You lose!","The number was:",N  I'm sure that this code is easy to understand — but why it's here might not be. Think about it, though: this code is right after the End of the For( loop. The For( loop repeated 10 times (once for each guess) without getting here — once it does, that means that 10 guesses have passed; and the player still hasn't guessed the number, or otherwise the program would have stopped. So once we're here, the player has lost the game. The thing to do now is to display the appropriate message, along with telling him what the right number was. Loops are a type of control structure used to repeat a block of code several times. Typically, there are two kinds of loops in programs: • A loop that repeats until a condition is satisfied • A loop that repeats a fixed number of times In TI-Basic, the first kind of loop is created with the While and Repeat commands, and the second kind is created with the For( command. # While and Repeat The syntax for these two loops is identical:  :While (condition) : ... : :End  :Repeat (condition) : ... : :End  In practice, however, they are different. The code inside a While loop will keep repeating as long as the condition is true ("do this while the condition is true"), and exit as soon as the condition is false. The code inside a Repeat loop will keep repeating until the condition becomes true ("Repeat this until the condition is true"). So a loop with While will have the opposite condition of the same loop with Repeat. There is another subtle difference. The While and For( loops are pre-test loops, which means the condition is checked before you enter the loop. If the condition is false, the loop is skipped entirely. However, the Repeat loop is a post-test loop as the loop is done at least once no matter what. The condition is only checked after a cycle is completed. # The For( Loop The For( loop is probably the most complicated command we've covered so far. Its syntax: :For(variable,start,end,step : :End  This loop will be repeated once for every value of variable between start and end, increasing it by step each time. For example, For(A,1,10,2) will be repeated once with A=1, then with A=3, then with A=5, then with A=7, and then with A=9 (then the loop stops, because the next value — 11 — is greater than the end value of 10). By default, the step size is 1, so you don't have to include the step if you want it to be 1. For example, this loop will display the numbers 1 through 10, in order: :For(A,1,10) :Disp A :End  You can also have a negative step size: in that case, the ending value should be less than the starting value, and the value of the variable will decrease each time. For example, this loop will display the same numbers 1 through 10, but in reverse order: :For(A,10,1,-1) :Disp A :End  # Some Common Loops Input validation Asking repeatedly is not the only way to make sure that input is valid; you might also exit the program if the input is bad, or find a way to interpret bad input as good. These methods are discussed in more depth in the Validation tutorial. One way to use a Repeat loop is to make sure that input is valid. For example: :Repeat X>0 :Disp "ENTER A POSITIVE" :Input "NUMBER:",X :End  This program will ask for a positive number in X. After that, the condition "X>0" will be checked — if X wasn't positive, the condition will be false, and the loop will be repeated. So the program will keep asking for a positive number until a positive number is actually entered. This might be useful if your program will not work with negative numbers. The simplest kind of Repeat or While loop is the infinite loop. This can be done by making Repeat's condition be 0 (false), or While's condition be 1 (true). In either case, the loop will keep going forever. Finally, For( loops have an unusual use to create delays. For example: :For(X,1,100) :End  This code doesn't actually do anything, but repeating the loop 100 times takes some time. This could be useful when you want to pause for a certain time (say, a few seconds) on a screen before displaying the next screen. Later in this tutorial, you'll learn about the rand command, which can be used as an alternative to For( in creating delays. Next up on the "control structure" miniseries, this page will explain the most general such instruction there is: the Goto command. The idea is simple: this instruction tells the calculator to go to another point in the program, and continue running it from there. Combined with the If command we've already mentioned, this is actually enough to define any sort of sequence of steps you like, even if it's not always the simplest way to do so. # Lbl and Goto Before telling the calculator to go to another point in the program, we need a way to identify that particular point. There could have been several ways to do this: for example, some ways use the line number. But counting lines in a large program would be a pain, and besides, you'd have to change everything if you inserted an extra line. So TI-Basic uses a different approach, the Lbl command. Using Lbl is simple: just put it (on a line by itself) at a point in the program you might want to jump to later, and add an identifier. The identifiers TI-Basic allows are one or two characters long, and made up of letters and numbers (so Lbl 0, Lbl XY, Lbl A5, and Lbl 99 are all valid labels). When the program is running normally, the calculator will just skip over a label as though it weren't there. But once you've made the label, you can use a Goto command to jump straight to it. Goto commands work the same as labels: you give it the identifier you want, and it will jump to the label with that identifier. For example, Goto 0 will jump to the line immediately after Lbl 0. # Some Uses Exiting a program Exiting earlier programs wasn't a problem. The calculator keeps going forward, so eventually it will get to the end! With Goto and Lbl, the calculator can jump backward in the program, so there's a danger of an infinite loop, when the program keeps repeating with no way to exit. An easy way to exit any Basic program is to use the [ON] key. This will display an error message (ERR:BREAK), and the program will finish running. Another possibility is with Input commands. Whenever you're in those, you can press [2nd][QUIT] to exit a program. The first really new thing that we can do with Lbl and Goto is looping over and over in a program. For example: :Lbl 0 :Disp "HA HA HA" :Goto 0  This will keep displaying "HA HA HA" repeatedly, and never stop. Without a way to jump around the program, we'd need an infinite number of lines to do this! You'll often want to pair a Goto with an If statement. Apart from infinite loops, there's not a lot of reasons to always make a jump. But paired with the If command, you can make the calculator go to entirely different parts of the program depending on a condition. This leads us to an important use of Goto: prematurely exiting a program. When you've written a large program, you might want to stop running it in the middle in certain cases. There are two commands — Return and Stop — that do just that, but Goto provides an alternative. Just make a label (for example, Lbl Q) at the end of the program. Then, you can Goto Q at any time to jump to that label, and exit the program from there. This is useful if you want to always do something at the end of the program, such as displaying "GOODBYE!". # More on the Subject More info on the Lbl and Goto commands can be found at their respective pages here and here. # The Menu( Command The Menu( command is one of the coolest uses of labels. It's another form of input: instead of asking the user to type in a value, you're asking the user to make a choice from a menu that looks almost exactly like the built-in menus. After displaying this Menu( and waiting for a choice, the Menu( command will jump to a label that depends on this choice. The syntax for Menu( is somewhat complicated. First comes a string (in quotes) for the title of the menu. The rest of the parameters come in pairs: a string, in quotes, for a choice in the menu, followed by the label for that choice. For example: :Menu("SAMPLE MENU","OPTION 1",1,"OPTION 2",2 :Lbl 1 :Disp "OPTION 1!" :Stop :Lbl 2 :Disp "OPTION 2!"  This sample program displays a menu called "SAMPLE MENU" with two options, "OPTION 1" and "OPTION 2". With either option, it will go to a label that displays the option you chose, and exits the program. Because of the size of the screen, you're limited to 7 options or less in a Menu( command. (NOTE: On the TI-84+ CE, you're allowed up to 9 menu options.) # Problems with Labels Despite the tremendous convenience of labels, there are two large problems with using them. The first is speed: jumping to a label can be a relatively slow task (for the calculator, at least). This is because the calculator needs to search through the entire program to find the label. It starts at the beginning, and keeps reading the program until it gets to the end. So if the program is large, and the label isn't at the very beginning, this could take a long time. The second is more complicated to explain. There are several commands that require an End to finish a block: we've seen this with the If-Then-End form of the If command. Whenever the calculator comes across one of these in a program, it has to use some memory to "remember" to look for an End. When it reaches the End, that memory is freed again. So what happens if you use a Goto or a Menu( to jump out of the block? The calculator will never find the End it's waiting for. So the memory it used up will never get freed (until the program ends altogether). In fact, if you end up doing this a lot, or even worse, if this is done repeatedly in a looping situation, the calculator will be using a large part of its memory just to keep track of these Ends (this is called a memory leak). Even if this doesn't reach the worst possible conclusion, an ERR:MEMORY, it will slow down the program a lot. These two problems are a motivation for the several commands we'll see in the next lesson, which provide a better way to do loops like the one we used Goto for in this section. In fact, jumping to the end of the program is one of the only reasons to use Goto, ever. ## More on the Subject More info on the Lbl and Goto commands can be found at their respective pages here and here. You can learn more about the Menu( command here. Validation is the process of evaluating user input to ensure it satisfies the specified requirements. Most programs just blindly accept any input that the user enters, assuming that it was entered in correctly and that it is valid. This is a dangerous assumption, because there is a great likelihood that somebody at some point will enter in bad input. When that finally happens, the program will crash when it tries to use the input. In order to ensure this doesn't happen, you should validate user input. When validating user input, there are three main approaches you can take: • Stopping the program — This validation approach involves asking the user for input, and then checking to see if it is a bad input value; if it is, you then just stop the program with a Return or Stop. The idea is that there is no point continuing on to the rest of the program, since the input would only cause the program to crash or get messed up when the input finally gets used. • Keep asking for input — This validation approach involves placing your validation inside of a Repeat or While loop, and using a variable as a flag to indicate whether the input is valid or not. The idea is that after asking the user for input, you check to make sure it is not a bad input value; if it is, the bad input flag will be set, and input will be asked for again. • Make bad input valid — This validation approach involves asking the user for input, and then trying to filter out any bad parts of the input that might be present. You can make the filters as in depth as you want, but because there is almost an infinite number of things that a user can enter in, there is no way to cover everything. Ultimately, it comes down to knowing the user, and what they are likely to enter in. # How to Validate Variables There are three main variable types that a user will be asked to input values for in a program: reals, lists, and strings. Each of these variables has their own set of standard validation considerations to check for, along with whatever additional considerations you have in your particular program. ### Reals When validating a real variable, the main things to check for are: • Is it within the appropriate range? • Is it not a complex number (i.e., there is no imaginary i part)? • Is it an integer (i.e., no fraction part)? • Is it positive (or zero, if appropriate)? Testing for these four conditions is relatively easy, considering that there are built-in commands that will take care of it for you: relational operators, the imag( command, and the fPart( command. Generally, you should do the complex number check before the other three checks, because an imaginary part in a number can cause problems. There's another problem that comes up with using Input specifically. If the input is for a real number A, the user might enter a list, which will be stored to ∟A instead. A simple way of fixing this problem is to store an invalid value to A to begin with, which will be dealt with if the user enters a list and doesn't change A. Many times, this is as simple as using DelVar. For a simple example of validating a real number, imagine asking the user to specify how many rounds of a game they want to play. A For( loop is used as the main game loop, with the number of rounds being the upper boundary. Since the lower boundary is zero, we want the user to input a number greater than zero. In addition, a For( loop does not work with complex numbers, and we do not want to allow a fraction part because the number of rounds is used to calculate the scoring. Here is what the validation code for our game might look like with each of the three different validation approaches:  :DelVar AClrHome :Input "ROUNDS: ",A :If imag(A :Return :If A<1 or fPart(A :Return  :0→A :Repeat Ans :ClrHome :Input "ROUNDS: ",A :If not(imag(A :not(A<1 or fPart(A :End  :DelVar AClrHome :Input "ROUNDS: ",A :max(1,iPart(real(A→A  There are a couple things you should note. In the stopping the program code, we used the Return command to stop the program, instead of the Stop command. This is so that the program will work correctly with subprograms and assembly shells. We used the opposite commands in the making bad input valid code: iPart( instead of fPart( and real( instead of imag(. We are also using the max( command to make one the minimum value for the input. ### Lists When validating a list, the main things to check for are: • Is the list length within the appropriate range? • Does each list element pass the real validation? Testing for the list length condition and each of the list elements involves using the built-in dim( command. You first check to see that the list length is acceptable, and then use the dim( command as the upper boundary in a For( loop to go over the list elements one at a time. Each element is validated just like a real variable. For a simple example of validating a list, imagine you have a lottery game and you want the user to specify three numbers. We want the numbers to be between 1-100, as well as not having an imaginary or fraction part. Here is what the validation code for our game might look like with each of the three different validation approaches:  :ClrHome :Input "NUMBERS: ",L1 :If 3≠dim(L1:Return :For(I,1,3 :L1(I :If imag(Ans:Return :If Ans<1 or Ans>E2 or fPart(Ans :Return :End  :Repeat A=3 :ClrHome :Input "NUMBERS: ",L1 :DelVar A :For(I,1,3(3=dim(L1 :L1(I :If not(imag(Ans :A+not(Ans<1 or Ans>E2 or fPart(Ans→A :End:End  :ClrHome :Input "NUMBERS: ",L1 :For(I,1,3-dim(L1 :randInt(1,E2→L1(1+dim(L1 :End :3→dim(L1 :max(1,min(E2,iPart(real(L1→L1  Like with the example from before, we had to check for the complex number before checking for the number boundaries and fraction part. This is because neither of those commands work with complex numbers; they will actually throw a ERR:DATA TYPE error. Also important is the optimization that we used to move the list dimension check into the For( loop's upper boundary. This allowed us to eliminate a conditional that we would have had to add. ### Strings When validating a string, the main things to check for are: • Is the string length within the appropriate range? • Does the string only contain the appropriate characters? Testing for the string length involves using the built-in length( command. This check by itself is not enough, however, because a string treats commands and functions as just one character (i.e., a string of "ABOutput(" is considered to be three characters long). The way you resolve this problem is by making sure the string only contains certain characters. This involves creating a string of acceptable characters, and then checking the user input against it. For a simple example of validating a string, imagine you have a two-player hangman game and you want the user to enter in an eight letter word, so that the other player can guess it. The only characters that are allowed are the uppercase alphabet (A-Z), and there is no restriction that the word has to actually exist. (Programming in a check for that would involve keeping a dictionary of words, and that could potentially take up a lot of memory.) Here is what the validation code for our game might look like with each of the three different validation approaches:  :"ABCDEFGHIJKLMNOPQRSTUVWXYZ :ClrHome :Input "WORD: ",Str1 :If 8≠length(Str1:Return :If not(min(seq(inString(Ans,sub(Str1,I,1)),I,1,8 :Return  :"ABCDEFGHIJKLMNOPQRSTUVWXYZ→Str0 :0:Repeat Ans :ClrHome :Input "WORD: ",Str1 :If 8=length(Str1 :min(seq(inString(Str0,sub(Str1,I,1)),I,1,8 :End  :"ABCDEFGHIJKLMNOPQRSTUVWXYZ→Str0 :ClrHome :Input "WORD: ",Str1 :For(I,1,8-length(Str1 :Str1+sub(Str0,randInt(1,26),1→Str1 :End :For(I,1,8 :If not(inString(Str0,sub(Str1,I,1 :sub(sub(" "+Str1,1,I)+sub(Str0,randInt(1,26),1)+sub(Str1+" ",I+1,9-I),2,8→Str1 :End  When the user inputs a word, we loop through all of the characters in the word and get their positions in our acceptable characters string. If any of the characters weren't in the string, then their position will be zero, and when we take the minimum of all the positions, the smallest will be zero. With the making bad input valid code, we also concatenate how ever many characters we need to make the word eight characters long. # Making Validation More Friendly There are a couple different ways you can make validation more user-friendly: displaying error messages when there is bad input, and storing input as a string and converting it to the appropriate variable type. Displaying error messages to the user when they enter bad input helps the user correct their mistake, and provides some direction on what input you are expecting them to enter. An error message does not need to be complicated or long — just enough so that you can get the point across. For example, say a program is a number guessing game, and the user is expected to enter in a number between 1-1000. If they enter 5000, you can display the message "Between 1-1000". Storing input as a string allows you to accept any input that the user may enter, even if it is messed up, entered in in the wrong format, or inappropriate for the variable that you are storing it to. This way instead of the program crashing when it gets bad input, it can actually handle it and do whatever it needs to to make it work. You then just check to see if the string has the appropriate value(s), and convert it to the desired variable using the expr( command. The validation for the real variable, for example, did not include a check for whether it is a list or string. This is because you can only really check for those things when you have a string that you can manipulate. If we wanted to add that check, we can search the string for an opening curly brace and commas or any characters besides numbers. If we find those things, we know that the input is bad, and we can reject it and ask for input again. In the case of the real variable, the other advantage of using a string is that you don't have to worry about whether the calculator is storing the variable to a list. More specifically, if a list is entered for input, the Input and Prompt commands will actually store the input to a list with the same name. This is possible because you don't need to include the character when referring to a user-defined list. (Entering a string would also work, and the string would become associated with the list.) Besides checking the list for whether it is a real variable or string, you also can check that it is in the appropriate format. When a list is entered, it needs to start with an opening curly brace, and then have each element separated by a comma. Because most users forget to include the opening curly brace, it is very convenient to place that at the beginning of the list yourself, so that the user never even knows about needing it. You can take that idea even further, and allow a list to be entered in many different ways: with commas and curly brackets, with commas and no brackets, as a list name (L1 through L6), or as a name starting with ∟, or as a name without the ∟. Instead of requiring one of these, the program might very well be programmed to handle all of them. This all comes down to finding alternate ways of making user input valid. # Thoughts to Consider The amount of validation you put in a program depends on how large and/or complicated the program is. If you have an extremely complex game with all sorts of user input, then it would be appropriate to include validation for some or most of those things. The general guideline is that the amount of validation needed correlates to the size of the game — i.e., a short math routine probably wouldn't need validation. While discussing validation, it is also important to mention that since the Input and Prompt commands only work on the home screen, you need to write your own custom input routine using the getKey command if you want to get input on the graph screen. If your entire program is already on the graph screen, however, this should not be an issue, because it makes perfect sense to maintain the user's attention on the graph screen. Most programs don't follow the same sequence of instructions every time. Depending on its input, a program might want to skip certain steps, or to follow alternative steps instead. Or maybe several instructions need to be repeated over and over again, for a certain number of steps or until they produce the right result. The next few parts of this tutorial will focus on control structures — instructions that explain which steps the calculator should follow, and in which order. Conditionals are the simplest control structure there is. The idea is simple: the calculator will check if a condition is true or false, and do entirely different things in each case. Of course, first we need to explain logic: what is true, and what is false. # Relations A note of caution The statements in this section are very similar to English, which is good because it makes understanding them easier. But it also leads to errors when they don't work the way you expect them to work. 0<X<10 seems okay, but it's not — it actually compares 0<X first, and compares the result (0 or 1) to 10, returning the wrong answer. Use 0<X and X<10 instead. The building blocks of a condition are the relations =, , >, , <, and . They can check if two numbers are equal or test if one is larger than the other. With these commands, the calculator can compute that 2+2=4 is a true statement, but 1<0 is false. Try some of these yourself! You can find the relations in the [2nd] [TEST] menu (the 2nd function of the MATH button). If you type some true and false statements on the home screen, you'll see something like this: 2+2=4 1 2+2>4 0 100≤10*10 1  This seems confusing! After all, I said that the calculator checks if a statement is true or false. Where do the numbers 1 and 0 come from? The answer is simple: because the calculator doesn't have separate values for "true" and "false" (which are known as boolean variables in other languages), it's forced to use the numbers 1 and 0 for the purpose. In this context, the value 1 means that a statement is true, and the value 0 means that a statement is false. Of course, in a program, you're probably not interested in checking whether 2+2=4: this check is going to be the same each time you run the program, so there doesn't seem to be a point. More likely, you'll be checking the values of variables, which as I've said can be used in place of numbers. For example, you might want to check if A=1, or if X≤0. # Logical Operators Building on relations, we can use logical operators to make more complicated conditions. The four operators are and, or, xor, and not(. You can find them by going to the same [2nd] [TEST] menu where relations were, then pressing the right arrow to go to the LOGIC submenu. Three of these operators — and, or, and not( — have clear meanings. X=2 and Y=2 means that both X and Y are equal to 2. X=2 or X=3 means that X is either 2 or 3. not(X=Y) means the opposite of X=Y, which we can also write X≠Y. Even here, we need to make a clarification. The word "or" has several meanings in English, and despite the similarity between the English word and the logical operator, the operator only uses one of these. Specifically, it uses the "inclusive or": if both parts are true, the whole thing is also true. This matches the English in some uses (if you need to pass math or science to get a diploma, you'll certainly get one if you pass both) but not in others (if the meal comes with soup or salad, you'll probably have to pay extra for both). If you do mean to describe an "either-or" situation, you'll need the xor operator, which stands for "eXclusive OR". This way, the calculator knows what you mean: if you write X=2 or Y=2, it's okay if both are 2, and if X=2 xor Y=2, only one can be 2. Like relations, logical operators deal with, and return, 1 and 0 to represent true and false. # Conditions In a program, we want to do more than just check if a statement is true or false. We want to do different things depending on this check. This is accomplished by several forms of the If command: ## Simple If :If (condition) :(statement)  This simplest form of the If statement imposes a condition on one other line of code. The statement directly after If will be skipped if the condition is false. It works just as it reads: "If X=2:Disp Y" means "If X is 2, display Y". ## If-Then-End :If (condition) :Then :(statement1) ... :(statementx) :End  One step beyond the simple form, this is what you do when several commands (sometimes most of your program) depends on the condition. Just put a Then immediately after the If - then all the statements until you reach an End will depend on the If condition. You can have one If statement inside another, layered as much as you want. It's traditional to write If (condition):Then on one line, separating them with a colon and not a new line. This makes code easier to read (you don't have to scroll as much) and looks more like other programming languages. Of course, this is purely voluntary. ## If-Then-Else-End :If (condition) :Then :(condition is true) :Else :(condition is false) :End  The most complicated form of If statement. In this case, an alternative action is provided. If the condition is true, everything between Then and Else is done. If the condition is false, everything between Else and End is done instead. There is no single-statement form for this. # Example Here is an example of the If statement in action. We've embellished the program from the previous section to only accept positive numbers as the side lengths of a rectangle. Now, it will still do the same thing if both A and B are positive — but otherwise it will display a message saying "BAD INPUT!" In the next two pages, we'll learn how to do one better, and actually keep asking for the numbers until they're positive. :Disp "ENTER NUMBERS >0" :Input "FIRST SIDE?",A :Input "SECOND SIDE?",B :If A>0 and B>0 :Then :Disp "PERIMETER:",2A+2B :Disp "AREA:",AB :Else :Disp "BAD INPUT!" :End  ## More on the Subject A more complex look at the implementation of logic can be found at the page on piecewise expressions here. Program Summary A quality DDR clone. Program Size 30KB Uses Libraries? Yes, xLIB Calculator Compatibility TI-83+/84/+/SE Author Kevin Ouellet (DJ Omnimaga) xLIB xLIB Revolution is a clone of the Dance Dance Revolution game using the xLIB Flash app. Unlike most other calculator clones, this one features quality graphics and runs pretty fast. It also includes a level editor that will allow infinite possibilities for the game. You can even have background images in songs and animations. This is one of the best TI-Basic DDR clones available. Program Summary A quality RPG. Program Size 120KB (not including most of RAM for in game use) Uses Libraries? Yes Calculator Compatibility TI-83+/84/+/SE (Because of the size and complexity, this game is only recommended for those with a 83+SE, 84+, or 84+SE) Author Kevin Ouellet (DJ Omnimaga) Reuben Question is a full-featured RPG, with a good storyline providing several hours of gameplay, flickerless grayscale graphics, complex puzzles, lots of monsters and plot twists, and many mini-games and side-quests. Of course, none of this is cheap in the memory department. The game literally takes up over 120KB in archive, with it spread out to almost fifty different programs (in particular, each of the maps and bosses are given their own program), and you need to have several of them unarchived in order to actually play the game. Of course, this does not include the actual in game usages that occurs from using all of the real variables, lists, matrices, and strings. Still, the game is a great achievement in TI-Basic, and surely stretches what people thought is possible. Program Summary A quality RPG. Program Size 120KB (not including most of RAM for in game use) Uses Libraries? Yes Calculator Compatibility TI-83+/84/+/SE (Because of the size and complexity, this game is only recommended for those with a 83+SE, 84+, or 84+SE) Author Kevin Ouellet (DJ Omnimaga) Reign of Legends is a full-length RPG, which features a good storyline with over 15 hours of gameplay, 3 playable characters, quality graphics and magic animations, four world maps, over seventy enemies, thirty locations with over 1,000 screens, and many mini-games and side-quests. Of course, none of this is cheap in the memory department. The game literally takes up over 120KB in archive, with it spread out to almost fifty different programs (in particular, each of the maps and bosses are given their own program), and you need to have several of them unarchived in order to actually play the game. Of course, this does not include the actual in game usages that occurs from using all of the real variables, lists, matrices, and strings. Still, the game is a great achievement in TI-Basic, and surely stretches what people thought is possible. Program Summary A quality version of the classic metroid game. Program Size 123KB (not including most of RAM for in game use) Uses Libraries? Yes, xLIB Calculator Compatibility TI-83+/84/+/SE (Because of the size and complexity, this game is only recommended for those with a 83+SE, 84+, or 84+SE) Author Kevin Ouellet (DJ Omnimaga) Metroid II features many items from the original metroid like the morph ball, bombs, wave beam, fake walls, destroyable blocks, full of secrets, awesome graphics, many traps, animations, several areas to explore (over 250 maps) and many things that will make your adrenaline increase to insane proportions while playing. Of course, none of this is cheap in the memory department. The game literally takes up over 123KB in archive, with it spread out to almost fifty different programs (in particular, each of the maps and bosses are given their own program), and you need to have several of them unarchived in order to actually play the game. Of course, this does not include the actual in game usages that occurs from using all of the real variables, lists, matrices, and strings. Still, the game is a great achievement in TI-Basic, and surely stretches what people thought is possible. Program Summary A quality version of the classic risk game. Program Size 5,717 bytes Uses Libraries? No, it's pure TI-Basic Calculator Compatibility TI-83/84/+/SE Author Arthur O'Dwyer Download worldempire.zip World Empire is a two-player, Risk-style war game against a computer opponent. The goal of the game is to defeat the computer ("Hal") by conquering all of its nations, leaving it with no way to raise an army. If Hal succeeds in conquering all your nations, on the other hand, then Hal wins and you lose. The map of the world is divided into 20 nations, each of which has two basic characteristics: its current owner and its underlying sympathies. In addition, each nation has one fundamental, immutable characteristic: its productivity, or "value." A nation's value represents how many troops it can produce per turn. For example, China's value is 5, while Greenland's value is only 1. Each nation also has up to four neighbors, with which it can fight or transfer troops. Program Summary A quality text adventure game. Program Size 6,700 bytes Uses Libraries? No, it's pure TI-Basic Calculator Compatibility TI-83/84/+/SE Author Arthur O'Dwyer Download castleadventure.zip Castle Adventure is a text adventure game in the style of Infocom or "Colossal Cave". Your goal is to enter the castle and make off with the king's treasure. To achieve this goal, you must solve puzzles by interacting with the game using simple English commands. The game uses full-text interaction, and an innovative input system. When the game is ready to accept input, a caret ">" will appear on the last line of the screen. Press an alphabetic key, and a word beginning with that letter will appear on the input line. For example, your first move might be to go WEST from the castle gate; therefore, you'd press the W key, and see the fully-formed word WEST appear on the input line. Program Summary A quality card game with AI. Program Size 5,300 bytes Uses Libraries? No, it's pure TI-Basic Calculator Compatibility TI-83/84/+/SE Author Arthur O'Dwyer Download commerce.zip Commerce is a three to five player game similar to Rummy, played against two to four computer opponents. There is no automated scoring in this game; rather the goal is to simply win more hands than your opponents. This game features some decent graphics and gameplay, as well as demonstrating good programming practices and code. Program Summary A quality puzzle game with donuts. Program Size 10,276 bytes Uses Libraries? No, it's pure TI-Basic Calculator Compatibility TI-83/84/+/SE Author Mikhail Lavrov (DarkerLine) Download donutquest.zip A world where the rich hoard donuts in heavily secured mansions, and the poor are left with nothing. A perfect world for a donut thief. Donut Quest is a TI-Basic game of revolutionary quality. It uses no libraries of any kind, in fact, you don't need anything other than the game program to play it. On each of eight levels, you must get to (and eat) all the donuts, then leave through an exit (unless given other instructions). There will be dangerous obstacles ahead of you, and the path will not be easy… but you can always triumph. Program Summary A quality version of the classic minesweeper game. Program Size 3,339 bytes Uses Libraries? Yes, xLIB Calculator Compatibility TI-83+/84/+/SE Author Fred Sparks (CDI) Download minesweeper.zip Minesweeper is another minesweeper clone programmed in TI-Basic. The main feature of this game is its grayscale graphics, which make it one of the best looking minesweeper games available. The game uses the standard controls: arrow keys move the cursor, 2nd uncovers a spot, and ALPHA flags a spot. Program Summary A quality version of the classic tetris game. Program Size 2,877 bytes Uses Libraries? No, it's pure TI-Basic Calculator Compatibility TI-83/84/+/SE Author nitacku Download tetris.zip Tetris is the smallest, fastest tetris clone programmed in TI-Basic. The game features quality graphics, increasing speed with each level, and a high score. The standard controls are used: left and right move a piece, down moves a piece down, and up rotates the piece. Program Summary A quality version of the classic checkers game. Program Size 13,249 bytes Uses Libraries? No, it's pure TI-Basic Calculator Compatibility TI-83/84/+/SE Author nitacku Download checkers.zip Checkers is a one or two player game that follows the standard checker rules for acceptable moves and scoring. The game features several customizable options, including saving and loading, who gets what color pieces, and an ability to change the game rules so that you can jump over your own pieces. The true highlight of this game, though, is its great AI. It comes with three levels of difficulty, with the strength of the AI being easy, medium, or hard. Unlike other games that just use a simple random number to decide which move the AI will take, this game actually uses sophisticated logic based on the rules of checkers. And to make the AI even better, you can have the AI play against itself. This tutorial is meant as an introduction to 68k TI-Basic for programmers that already are fairly experienced with TI-83 series Basic programming. Instead of re-teaching many things, this tutorial highlights the differences between the two languages.  Table of Contents # Major Features A major novelty of the 68k calculators is the ability to make symbolic calculations. This has many applications: you can deal with expressions such as x2+2*x+1 but treat x as an unknown, or deal with the exact value of √π/3 without approximating it with floating-point values. The calculator no longer has some statistical commands, but has much more powerful calculus commands (it can do symbolic derivatives, integrals, and finite and infinite sums, among other things). This doesn't have any immediate programming applications, although you can often find an unexpected use for these commands. A very programming-relevant difference, on the other hand, is the advent of error catching. Using the Try and EndTry statements, your program can identify if an error has occurred, and possibly even recover from this (or at least display a custom error message). Also one of the highlights is how much pictures have been empowered. They now can be any size and be displayed with any logic. True "real-time" multiplayer games is now possible with the SendCalc Command, something that was impossible on 83's. The more specific differences described below tend to combine to make programs run faster, and allow for a programming style closer to programming a more "serious" language on a computer. # Commands On the TI-89, commands can be entered letter by letter, and don't have to be chosen from a menu. In practice, programs and functions are tokenized, making a command range take up 1 to 3 bytes in a program. Many commands have been added or removed between the two languages (see the command index for a full list of commands). In addition, the following commands have changed in spelling: There are two more overall changes. First, many commands' names have been truncated where they were longer than 8 characters: this is the maximum for a command name on the TI-89. An example is RclPic, the 68k equivalent of RecallPic. Second, the use of parentheses after a command now follows a strict convention. • "Instructions" — commands that do not return a value — do not require parentheses (e.g. If, Text, etc.) • "Functions" — commands that do return a value — require parentheses (e.g. sin(), setMode(), etc.) • Even functions with no arguments use parentheses (e.g. getKey(), startTmr(), etc.) Many commands have been added. However, as far as statistics goes, the 68k calculators are inferior, even, to the TI-83 series; most of the functionality is now restricted to regressions, and the calculator doesn't even know internally how to calculate most probability distributions. # Variables The way variables are stored has undergone major changes from the TI-83 series. All variables now share a common naming system: the name of a variable can be up to 8 letters long. Variables can also be placed in different folders, which can't be nested but otherwise are very similar to file folders on a computer. By default, variables are stored in the folder 'main'. On the surface, the variable types are much the same as they were on the TI-83 calculators: you have numerical variables, lists, matrices, strings, picture variables, equations, graph databases, and a new one, called "data". These are slightly different, however. To begin with, numerical variables can now be either floating-point (the same as on the TI-83 series) or integer variables (that don't have a decimal place, but have several hundred digits of precision). As a consequence of the symbolic operations on a 68k calculator, you also have expressions: formulas that are only evaluated as much as possible. List are very different. They now can hold any combination of numbers, expressions, and character strings. This makes them more powerful, but also slows them down significantly. Data's are basically matrices, but with the new capabilities (and speed limitations) of the new lists. Matrices stayed the same though, limited to numbers, but retained their speed. You can effectively emulate an "old style" list by using a matrix with only 1 row/column, Boolean variables will also cause some confusion for TI-83 programmers: Instead of boolean (true/false) operations returning a one or a zero that can be used in the same manner as regular integers (1, 3, -5, 4.8, etc.), boolean variables now all have a class of their own. This means that you can't use a simple "If (variable)" statement to check whether a variable has yet been defined, and can't use shortcuts in expressions that involve a parenthetical boolean statement determining whether a certain term in the expression is used (e.x. (k>2)(x+1)+3x). Instead, you will have to use the ifVar() command to check whether a variable has been defined and return to regular If-Then blocks for conditional computing. # Programs Programs are also considered variables, on the same level as any other: you can even define a program within another program. They imitate built-in commands, and can even be given parameters. Using the Local command, you can declare local variables that are reset to their old values once a program finishes running. You can also define functions, which are similar to programs but return a value. Functions have some other limitations, though: they can only use local variables, and can't modify any global aspects of the calculator (so graphical commands, for example, are limited to programs). With local variables, and the ability to define functions and programs, you can program in a procedural language style. Instead of placing the entire code of the program in one block, you can split it up into functions and subprograms that are defined at the beginning of the main program. The entire issue of memory leaks (caused on the TI-83 series by jumping out of code blocks with Goto) is no longer present in 68k TI-Basic. Loops have offsets linking the end to the beginning, so the program doesn't need to keep a stack to be aware of what to do with End instructions. There is no longer any memory cost to entering a loop (or any other kind of code block), so it's impossible to leak memory this way. # Optimizations Most types of trivial optimizations from the TI-83 series are invalid on the 68k calculators. For example, closing parentheses, quotes, and brackets are now mandatory — but don't add any size to the program, since it's tokenized and converted to postfix notation. The Ans variable no longer plays an important role: though the ans() command does exist to replace it, it's not modified by storing to variables inside a program, so it's mostly useful on the home screen. A large part of 68k optimization revolves around careful use of lists. List variables are no longer random access: accessing the last element of a list is much slower than accessing the first element. For this reason, going through a list in a For loop is about the worst thing you could do. # Graphics 68k gives the programmer much more options with displaying graphics. Sprites, which had to be displayed using various tricks or libraries on a TI-83 series calculator, are built into 68k as picture variables. These picture variables bear little resemblance to the screenshot-like functionality they have on a TI-83+. They can be any size from 1x1 to the entire screen, and can be stored from and recalled to any part of the graph screen. There are even several commands for displaying a sprite using different logic. Apart from these very powerful commands, more ordinary commands have also been buffed up. Virtually all graphics commands have a point and a pixel equivalent, so you're free to choose one or the other to use (usually, you'll want pixels). The Circle command now draws circles instantaneously, as opposed to taking several seconds. Instead of being forced to choose between home screen and graph screen, the choice is between graph screen and "Program I/O" screen on the 68k calculators. The program I/O screen is a separate home screen for programs, which is limited to text (but the text doesn't have to be aligned). In addition, both screens can be spiced up using dialogs, which imitate the appearance of a popup window on a computer, and are great for inputting data without having to erase anything from the screen. Another major addition to the graphics command set is the newly created Dialog feature. New commands add extra I/O capability that doesn't interfere with the program I/O or the graph screen, allowing for enhanced in-program data entry. There is one limit to graphics on the 68k calculators - they cannot draw over the top menu bar and bottom status bar, so are effectively limited to only 2/3 of the screen. Assembly libraries can be used to access the entire screen, but this is impossible in TI-Basic alone. # Closing Words This page gives an overview of some of the features of 68k, but it isn't, and cannot, be complete. There are other pages you could visit to get a better picture of 68k programming: However, the best way to try to learn the language is first-hand experience with it. Program Summary A quality version of the classic solitaire game. Program Size 3,993 bytes Uses Libraries? No, it's pure TI-Basic Calculator Compatibility TI-83/84/+/SE Author nitacku Download solitaire.zip Solitaire is a card game that involves moving cards around, with the goal of making four stacks of cards (one per suit) in ascending order from Ace to King. The game features nice graphics, as well as good speed and size. The standard controls are used: arrow keys to move, CLEAR to quit, 2nd to select card, ALPHA to draw card, and GRAPH to set a card. Program Summary A quality version of a bowling game. Program Size 16,384 (is a Basic Builder app) Uses Libraries? Yes, xLIB Calculator Compatibility TI-83+/84/+/SE Author nitacku Download bowling.zip Bowling is a superb TI-Basic game that features quality gameplay and graphics. You start out with1,000, and you need to make it to the bowling World Championship. You compete against increasingly difficult opponents, although you can purchase items to enhance your skills and abilities. This is a truly fun game.

Program Summary

A quality version of the classic yahtzee game.

Program Size

6,329 bytes

Uses Libraries?

No, it's pure TI-Basic

Calculator Compatibility

TI-83/84/+/SE

Author

Brad Wentz

Download

yahtzee.zip

Yahtzee is the classic dice game everyone knows. This game is completely graphical, has support for up to 4 players, a save game option, saves high score, displays which categories you qualify for, and runs really fast. This game has all of the rules from the real game, including using the yahtzee as a joker.

Program Summary

A suite of tools for editing text, presenting slides, and making graphics.

Program Size

8,575 bytes (Document XE)
6,256 bytes (Presentation XE)
6,245 bytes (Draw XE)

Uses Libraries?

No, it's pure TI-Basic

Calculator Compatibility

TI-83/84/+/SE

Author

Brad Wentz

Download

officexe.zip

Office XE is a full-featured office package that includes a text editor, presentation/slide show maker, and a graphics program. Each program has a similar interface so if you can use one you can use them all. All of these programs are very advanced and include features never seen before in basic programs.

• Document XE — A fast, advanced text editor with an easy to use interface.
• Presentation XE — An easy-to-use slideshow maker with a simple way to organize pictures and create a presentation.
• Draw XE — A very sophisticated drawing program, with all drawing done on the fly and and several different drawing tools and options available.

Program Summary

A quality version of the classic chess game.

Program Size

6,869 bytes

Uses Libraries?

No, it's pure TI-Basic

Calculator Compatibility

TI-83/84/+/SE

Author

Francis Huang

Download

chesspro.zip

A chess game that is relatively small and fast, and features move checking, three save slots, and auto-saving. It is one of the best TI-Basic chess games available.

Program Summary

A quality version of the classic dots game.

Program Size

1,311 bytes

Uses Libraries?

No, it's pure TI-Basic

Calculator Compatibility

TI-83/84/+/SE

Author

Travis Fischer

Download

dots.zip

The classic game of Dots (aka Boxes), popularized by the pencil & paper version, where two or more people take turns connecting a grid of dots with lines in an attempt to form complete boxes. The player who completes the most boxes wins! Features include: 2-9 players, customizable grid width/height, extremely intuitive game controls, and even a preview cursor which shows the user what a line would look like if placed in the current position.

Program Summary

A quality version of the classic bomberman game.

Program Size

4,969 bytes

Uses Libraries?

No, it's pure TI-Basic

Calculator Compatibility

TI-83+/84/+/SE

Author

Travis Fischer

Download

bomberman.zip

This is a graphical rendition of the classic Bomberman genre! The objective of the game is to progress through as many levels as you can, blowing up enemies/bricks and making it safely to the exit. Features include multiple level setups, difficulty settings, randomly generated levels, in-game instructions, and excellent animated graphics.

Program Summary

A quality version of the classic tower of Hanoi game.

Program Size

2,783 bytes

Uses Libraries?

No, it's pure TI-Basic

Calculator Compatibility

TI-83/84/+/SE

Author

Martin Johansson (Smoother)

Download

towerofhanoi.zip

The goal is to move all the blocks from one peg to another, and up to thirteen blocks can be changed by the player. A high score is saved for each level, which makes it a simple, but fun game.

Program Summary

You have to shoot down the buildings before you crash into them.

Program Size

1,863 bytes

Uses Libraries?

No, it's pure TI-Basic

Calculator Compatibility

TI-83/84/+/SE

Author

Martin Johansson (Smoother)

Download

blizz.zip

You have to shoot down the buildings before you crash into them.

Program Summary

A quality version of the classic Sims game.

Program Size

13KB

Uses Libraries?

No, it's pure TI-Basic

Calculator Compatibility

TI-83/84/+/SE

Author

Kerm Martian

Download

civilizationsimulator.zip

Modeled on popular computer games, Civilization Simulator lets you control and build an ancient civilization. It uses the ps3d engine, built specifically for this purpose, that provides extremely good graphics in 3D. You start with a blank world and must create people, structures, and trade for your people. The goal is to earn food and wood; when you have enough and have completed sufficient research, you can advance to the next age. After the successful completion of the third age, you win.

Program Summary

A quality version of the classic risk game.

Program Size

10KB

Uses Libraries?

No, it's pure TI-Basic

Calculator Compatibility

TI-83/84/+/SE

Author

Kerm Martian

Download

worlddomination.zip

World Domination is a real-time strategy game based on games such as Risk; you battle the calculator AI for control of the world. Each player starts with several units to place around the map of the world, then take turns moving, attacking, and redeploying. If you or the calculator gains control of a continent, you get a number of bonus units. Defeat all enemy troops to win the game.

This page needs to be . You can help improve TI-Basic Developer by fixing any errors, including any missing information, and adding links to other pages.
This article is a stub. You can help TI-Basic Developer by .

This is the hall of fame for all programmers who win a challenge at TI|BD.

Challenge # Program Program Description Winner
Challenge 1 TIBD01.zip Rolls user-specified # of dice
Challenge 2 TIBD02.zip Analog clock w/ AM/PM and date
Challenge 3 TIBD03.zip Game introduction (The Matrix)
Challenge 4 TIBD04.zip Converts decimal to Roman numerals
Challenge 5 TIBD05.zip Converts numbers to words
Challenge 6 TIBD06.zip A Custom GUI
Challenge 7 CANCELED Create a program that does the order of operations backwards. CANCELED
Challenge 8 TIBD08.zip A game that is less than 1024 bytes large
Challenge 9 TIBD09.zip Custom GUI

Darts is a simple game where you want to hit the target ("]") with your dart (">"), while avoiding the obstacles ("^" or "v") in your way. You get one point for each target you hit, and since there are twenty rounds, the maximum number of points is twenty. Although this game is rather simple at its core, it is extremely compact, and a good example of what you can do in a small number of bytes. Like with the other games, try out the game and try to understand and think through the code.

 Table of Contents

## The Code

:"Ans+8(not(Ans)-(Ans=9→u
:"1-2int(2rand→v
:"randInt(1,8→w
:DelVar SFor(I,1,20
:seq(w,J,1,3→L1
:seq(4J-v,J,1,3→L2
:seq(v,J,1,3→L3
:w→A:1→D:w→B
:DelVar Ev→C
:Repeat D=16 or max(A=Ans and D=L2
:ClrHome
:getKey→K
:If Ans=45:Goto Q
:If Ans=21:1→E
:Output(A,D,">
:Output(B,16,"]
:For(J,1,3
:Output(L1(J),L2(J),sub("^ v",2+L3(J),1
:End
:A+(Ans=34)-(Ans=25
:u→A:D+E→D:B+C
:u→B:L1+L3:u→L1
:End
:S+(A=B and D=16→S
:End
:Lbl Q
:ClrHome:S


## The Download

In case you want to try the program on your calculator, you can download the program in .8xp format.

Chase is a simple game where the goal is to chase down the randomly moving target. To make the game more difficult, the old locations of the target are not erased, which makes the target harder to find. This game is small in size and just uses a few real variables. Like with the other games, try out the game and try to understand and think through the code.

 Table of Contents

## The Code

:1→A:1→B
:8→C:16→D
:ClrHome
:Repeat A=C and B=Ans
:getKey→K
:If Ans=22:Stop
:If Ans:Output(A,B,"  // 1 space
:A+(Ans=34)-(Ans=25
:Ans+8(not(Ans)-(Ans=9→A
:B+(K=26)-(K=24
:Ans+16(not(Ans)-(Ans=17→B
:Output(A,Ans,"X
:Output(C,D,"+
:C+randInt(-1,1
:Ans+8(not(Ans)-(Ans=9→C
:D+randInt(-1,1
:Ans+16(not(Ans)-(Ans=17→D
:End
:Pause "FOUND IT!
:ClrHome:"


## The Download

In case you want to try the program on your calculator, you can download the program in .8xp format.

Program Summary

A 1 or 2 player basketball dunking game.

Program Size

4,200 bytes

Uses Libraries?

No

Calculator Compatibility

TI-83/84/+/SE

Author

Jason Russell

Download

slamsession.zip

While there aren't many sports games in TI-Basic, this game breaks that mold. The game involves playing against either another player or the calculator, and taking turns trying to make the best dunk possible. Each dunk is given a score from 1-10, and the player with the best cumulative score after three dunks wins.

The most basic dunk is just the standard slam dunk with one hand. You can increase the difficulty, though, by turning your body 180 degrees or doing a two-handed dunk; the more difficult the dunk, the higher the score. The game uses some simple controls: up to jump, right to run, left to stop, and CLEAR to reset.

This game is primarily just a fun time-waster, since once you memorize the best dunk combination, you can always be assured of beating or tying the other player or computer.

Program Summary

A quality version of the classic scorched earth game.

Program Size

3,670 bytes

Uses Libraries?

No, it's pure TI-Basic

Calculator Compatibility

TI-83/84/+/SE

Author

Sean Weeks

Download

bangbang.zip

Bang Bang is a scorched earth clone that involves two players methodically shooting missiles at each other until one of them blows up the other's base. There are three different missile sizes to choose from — small, medium, and large — and each of the missiles has advantages and disadvantages. In addition, there is a wind that affects the missiles, and thus changes which missile you use.

The main feature of this game is that it provides three different modes of gameplay: 1 player, playing against a target; 2 player, playing against another person; and vs. AI, playing against a challenging AI. In addition, the terrain is randomly generated, although you can specify your own custom terrain from the menu as well.

Rock Paper Scissors is a classic game that involves two players choosing among three different hand gestures, and seeing who has the best hand. Each of the hand gestures — rock, paper, and scissors — beats one of the other two hand gestures, so there is a good likelihood that somebody will win. (However, if both players choose the same gesture, it is a tie.) You can play this game indefinitely, but it does get monotonous after a while.

Here is a handy table that tells which hand gesture wins in each situation:

Rock Paper Scissors Tie Paper Rock Paper Tie Scissors Rock Scissors Tie
 Table of Contents

## The Code

:ClrHome
:Disp "PAPER - SCISSORS
:Input "ROUNDS:",I
:For(I,1,I
:ClrHome
:Disp "CHOOSE WEAPON:
:Disp "1) ROCK","2) PAPER","3) SCISSORS
:Repeat 2>abs(Ans-2
:getKey-91→J
:End
:Disp "YOU: "+sub("ROCK    PAPER   SCISSORS",8J-7,8
:randInt(1,3
:Disp "CALC: "+sub("ROCK    PAPER   SCISSORS",8Ans-7,8
:Pause "WINNER IS "+sub("YOU CALCBOTH",1+4max(Ans={1,2,3} and J={3,1,2})+8(J=Ans),4
:End
:ClrHome:"


## The Download

In case you want to try the program on your calculator, you can download the program in .8xp format.

As a way to test your comprehension of the information, and to ensure that you actually read through the information
instead of merely skimming over it, we have provided review exercises. These exercises provide a way of helping you apply the information, so that you get a fuller understanding of the concepts.

1. True or False: The ClrHome command should be used at the end of a program, to ensure that the program does not leave any leftover text on the home screen.

Answer: True. Although you still will have a Done message at the end. To eliminate this you can add this to the end of your code Output(1,1,"

2. What type of variable cannot hold a complex number?

Answer: Matrix.

3. Which of the following uses of the Disp command returns an error?

1. Disp
2. Disp ""
3. Disp "Hello World
4. Disp "Hello","World
5. None of the above.

Answer: None of above.

4. Which draw command cannot be called from a program?

Answer: Pen. It's technically not a command, but it is accessed in the draw menu like a command.

5. What is the difference between the iPart( and int( commands?

Answer: The difference between iPart( and int( is subtle, and many people aren't even aware of it, but it exists. Whereas iPart( always truncates its parameters, simply removing the integer part, int( always rounds down. This means that they return the same answers for positive numbers, but int( will return an answer 1 less than iPart( for (non-integer) negative numbers. For example, iPart(-5.32) is -5, while int(-5.32) is -6.

6. True or False: Programs can use the home screen for everything they can do on the graph screen.

Answer: False. There are no graphics commands available on the home screen.

7. What is the minimal modification that will allow this code to start-up?

:Menu("Choose One,"Menu Item",1,"Menu Item",2
:Lbl A
:Pause "Item 1
:Stop
:Lbl 2
:Pause "Item 2

1. Add a closing quote on the menu title.
2. Remove the Stop command.
3. Change Lbl A to Lbl 1.
4. Add a closing quote on the menu title and change Lbl A to Lbl 1.

Answer: Add a closing quote on the menu title.

8. In a statistics class, the teacher asks the students to generate a list of 100 random numbers. Unfortunately, the exercise doesn't work as intended because 22 students, in a class of 30, get the exact same numbers (using different calculators). What's a likely explanation for this surprising coincidence?

Answer: They all had the rand command seeded to zero.

9. How many digits of accuracy does the TI-OS have? How many can it display on the screen?

Answer: It has fourteen digits of accuracy, but only ten will be displayed.

10. The Output( command can display text at any place on the screen, but what happens when the text goes past the end of the line?

1. Nothing. The text simply does not show up.
2. An error is returned.
3. The text will wrap around to the next line.
4. An ellipsis will be displayed at the end of the line, with the rest of the text not being displayed.

Answer: The text will wrap around to the next line.

11. True or False: You need to use a Pause command before clearing the screen, otherwise the user will only see the text on the screen for a couple seconds; it will be a blur.

Answer: False. There are other options available, including using the rand command for a short delay or using a small Repeat getKey:End loop.

12. When is using the Menu command appropriate, and even desired? (Choose the best answer.)

1. If you want a generic menu.
2. Your program is going to be text-based.
3. It is the most practical menu available in your situation.
4. You want your program to stand out, so you need a fancy menu.

Answer: The first three answers are all good, but the best answer is if you want a generic menu.

13. What would be the effect of replacing a Disp command with an Output command and vice versa? Give any instances where this switch might be useful.

Answer: The Output( command doesn't scroll the screen when it gets to the bottom, like the Disp command does. The main instance where this is useful is when you have lots of text that you are displaying, and the Output( command will wrap it around to the next line.

14. What is the maximum dimension of a list?

Answer: 999. Note, however, that a list that size would barely fit in RAM.

15. Which one statement is true about this code?

:Menu("","",B,"",B
:Disp "Test
:Lbl B
:Disp "Pizza
:Output(1,1,"Spaghetti

1. An error will be returned when the Menu( command is executed.
2. The program will execute, but there will not be any text displayed.
3. The "Test" text will be displayed along with the "Pizza" and "Spaghetti" text.
4. The "Pizza" and "Spaghetti" text will be displayed, but not the "Test".

Answer: The "Pizza" and "Spaghetti" text will be displayed, but not the "Test".

16. True or False: Before using the Menu( command, you need to clear the home screen, otherwise you will have text interrupting the menu.

Answer: False. The Menu( command uses its own screen, which is separate from the home screen.

17. Consider the following code:

:0:Menu("Difficulty","Easy",3,"Medium",2,"Hard",1
:Lbl 1:Ans+1
:Lbl 2:Ans+1
:Lbl 3:Ans+1


The Ans variable keeps track of the last answer, often being used in place of more permanent variables. If the user selects the "Hard" menu item, what will Ans's value be? What effect does the label ordering have on the value, if any?

Answer: Ans's value will be three. The label ordering causes the value of Ans to be incremented by one for each difficulty level.

18. True or False: Using the home screen is faster than using the graph screen?

Answer: False. Both take the same time.

19. Which of the following cannot be used to test if a variable is any of 1, 2, 3, or 4?

1. If sum(A={1,2,3,4
2. If (A=int(A))(A>=1)(A<=4)
3. If A={1,2,3,4}
4. If A(int(A)=A)(A<5)

Answer: If A={1,2,3,4} because the If command does not work with lists.

20. True or False: The following is an alternate to using the or operator.

:If (X=1)+(X=2


Answer: True.

21. Name a command or function that cannot be interrupted by pressing the [ON] key.

Answer: randBin(, SortA(, and SortD( all will work.

22. For which of the following would not(B) not equal 0?

1. .01→B
2. 0→B
3. π→B
4. -4→B

Answer: 0→B. Remember that not( negates the value, so 0 becomes 1.

23. True or False: The following is an alternative to using the and operator.

:If Anot(B


Answer: True. Remember that multiplication is implicitly done on the TI-83 calculators.

24. How many bytes is an uppercase character? A lowercase character?

Answer: An uppercase character is one byte, while a lowercase character is two bytes.

25. Which of these user-created list names are actually possible on the calculator?

1. L1234
2. LBaDd
3. Lθθθθ
4. LABCD

Answer: Lθθθθ and LABCD. A list can't start with a number, and lowercase letters aren't allowed.

26. What type of variable needs a special command to store to it?

Answer: Picture and GDB. You use the StorePic and StoreGDB command.

27. Change this short program so it doesn't flicker and then optimize it as much as possible.

:4→X:4→Y:Repeat 0
:ClrHome
:Output(Y,X,"X")
:getKey→K
:If K=24:X-1→X
:If K=25:Y+1→Y
:If K=26:X+1→X
:If K=34:Y-1→Y
:End


Answer: Here is one possibility:

:4→X:4→Y:Repeat 0
:Output(Ans,X,"X
:Repeat Ans:getKey→K:End
:Output(Y,X,"  // 1 space
:X+(Ans=26)-(Ans=24→X
:Y+(K=34)-(K=25→Y
:End


28. True or False: You can archive another program from within a program.

Answer: False. You can, however, archive another program outside a program.

29. What is the maximum length of a string?

Answer: There is none. It is only limited by the amount of RAM.

30. Which of the following variables is it possible to archive?

1. Y1
2. prgmKEWLGAME
3. the real variable T
4. the real variable A
5. ∟RESID
6. L1

Answer: prgmKEWLGAME, the real variable A, and L1. Trying to archive Y1T,, and ∟RESID will give you an ERR:VARIABLE error.

31. Without trying it first, is this legal?

:[A]L4([A]([A](L1(1),L2(1)),L1(1(L2(2L3


Answer: No. While the syntax is correct, an error is returned when trying to get the particular element multiplied by the entire L3 list.

32. How would you find the fifth element from the last in a sequence of 20 elements?

Answer: Assuming the list is L1, you would just use:

:L1(15


33. What will this code do?

:DelVar B1→A
:If A:If B
:Disp "Hello World


Answer: Nothing. It doesn't output anything on the screen.

34. How do you get rid of the Done message at the end of a program?

Answer: You can remove the "Done" message that appears after a program is finished running by placing an expression, some text, or just a quote on the last line of your program.

35. Write a program that inputs a string and outputs the letters backward, one per line.

Answer: Here is one possibility:

:Input "TEXT:",Str1
:For(X,length(Str1),1,-1
:Disp sub(Str1,X,1
:rand(10
:End


36. Will this code execute?

:If 0:Disp "Your turn
:Else:Disp "Guess not


Answer: No, it will give you an error.

37. What is the simplest program you can have that has recursion?

Answer: A one-liner that just calls itself:

PROGRAM:A
:prgmA


38. Which of these are logically equivalent?

1. not(P or Q)
2. P and Q
3. not(P and Q)
4. not(P) or not(Q)
5. not(P) and not(Q)

Answer: "not(P or Q)" and "not(P) and not(Q)" are logically equivalent, while "not(P and Q)" and "not(P) or not(Q)" are logically
equivalent. This is based off of DeMorgan's Law.

39. True or False: There are actually 256 picture variables on the calculator, even though only 10 picture
variables show up.

Answer: True. Although the other 246 must be accessed through asm.

40. What are the differences between assembly and TI-Basic? When would you use assembly and when would you use TI-Basic?

Answer: Unlike TI-Basic, which uses commands and functions that are easy to understand, assembly is programmed in the calculator's own machine language, and thus is much harder to program in and read. You would use assembly when you want your program to be fast, and you would use TI-Basic when you want to program your game fast.

41. How long will the program go through the loop until it stops execution?

:0→X
:While X
:Disp "Another Loop
:X+1→X
:If X=25
:Stop
:End


Answer: Trick question the while loop is false.So X never changes and it ends at 0.

42. What is wrong with this code?

:If X=25 Then
:Disp "X is 25
:X+1→X
:Disp "X is now", X
:End


Answer: You need to change the space between X=25 and Then to a colon, and remove the space to the left of the second X in Disp "X is now", X:

:If X=25:Then
:Disp "X is 25
:X+1→X
:Disp "X is now",X
:End


43. What are the only keys that will be repeated if they are held down?

Answer: The arrow keys and DEL.

44. How would you go about converting a list to a matrix? What would the code look like?

Answer: Just use the List►matr( command.

45. True or False: There is no built-in way to convert a string to a number.

Answer: False. The expr( command does this.

Routine Summary

Looks through a list to find the first non-zero element.

Inputs

list - The list or list variable to look through.

Outputs

The index of the first non-zero element in the list.

If all the elements are zero, the result is one greater than the size of the list.

Variables Used

None erased.

Calculator Compatibility

TI-89/92/+/V200

:firstnz(list)
:1+sum(floor(1/(1+cumSum(abs(list))))


This function finds the first non-zero element in a list, and returns its index.

The innermost part of the formula makes the list easier to deal with: abs() makes all non-zero elements positive, then cumSum() ensures that after the first non-zero element, every next element in the result is also non-zero. After this, the list begins with some number of zeroes (possibly none at all), then only positive numbers. Now, to find the index of the first non-zero element, we must find the number of zero elements, and add 1.

The function floor(1/(1+x)) sends 0 to 1/(1+0)=1, and every positive number to 0. After we apply it to the result above, all the zeroes are replaced by 1, and all the other numbers by 0. Then, sum() adds all the 1s, counting the number of elements that used to be 0. Adding 1 to the result gets the index of the element one past all the zeroes, which is the result we want.

This explanation still doesn't answer the real question: why such a bizarre approach when a more simple one is possible — going through the list in a For..EndFor loop, and checking if each element is 0 until you get to one that's not? The answer is that accessing list elements one by one is very slow: to get to a middle element of a list, the calculator must go through all the elements before it. This means that when you access a list's elements in a For loop, you're going through the entire beginning of the list each time the loop cycles.

To avoid this, we use commands that deal with all the elements of a list at once. Because their code is written in the calculator's own assembly language, it doesn't have to go through this rigmarole to access a list. As a result, the strange-looking routine is faster, and its advantage becomes greater and greater with long lists.

# Error Conditions

210 - Data type happens when the input is not a list.

Program Summary

A remake of the Puzzle Pack game Dino Puzzle.

Program Size

2,357 bytes

Uses Libraries?

No, it's pure TI-Basic

Calculator Compatibility

TI-83/84/+/SE

Author

Alex Snyder (axcho)

Download

dinoeggs.zip

Dino Eggs is a remake of the popular Dino Puzzle game from the Puzzle Pack application released by Detached Solutions. The objective is to match falling shapes with similar shapes on the field. You do this by moving a cursor and switching two rows at a time to align them with the two incoming shapes before they land and another pair descends.

As you can see in the screenshot, the game runs on the home screen, and uses simple text for the cursor and everything else. Of course, the main feature of the game is that it provides almost unlimited gameplay, since the shapes are randomly selected and they keep descending until you lose or quit.

If you get tired, you can save the game and come back to it at a later time. Similarly, the game stores the highest score, so you can compete with friends to see who is the king. The game uses the standard controls: up and down move the cursor, 2nd switches the two selected rows, MODE saves the game, and CLEAR quits.

Program Summary

A game similar to falldown, but with a fun twist.

Program Size

1,120 bytes

Uses Libraries?

No, it's pure TI-Basic

Calculator Compatibility

TI-83/84/+/SE

Author

Alex Snyder (axcho)

Download

snakeescape.zip

Snake escape is similar to the game falldown, with the main difference being that you have to avoid a snake while collecting bananas. You can move left and right, and if you go off the screen, you will wrap around to the other side. In addition, if you go over a gap, you will fall down to the next level.

As you can see in the screenshot, the game runs on the home screen, and uses simple text for the snake and everything else. Of course, the main feature of the game is that it provides almost unlimited gameplay, since the gaps in each level are randomly generated and the levels keep going until you lose. The only controls in the game are left and right to move.

The following table proposes an extension to the (incomplete) set of ASCII codes classically exported by TI-GRAPH LINK, emulated by those with limited access to better portrayals of targeted characters, and utilized by those seeking to preserve their content in the 7-bit range. Each consists of no more than eight characters.

Cells containing symbols that already have 7-bit encodings are omitted. This includes letters and digits, brackets and other punctuation, and the alternate figures found on the number keys of most keyboard layouts. Each of these items can be typed out like normal, or encased in backslashes wherever convenient or necessary.

This is an alternative, often last-resort approach to rendering the TI-83 Plus font on a computer. Environments that support UTF-8 might be more well-suited for Unicode characterizations that rise above the 7-bit limit. For ways to represent TI-83 Plus characters in their full splendor, see the TI-83 Plus Large Font article.

Table of ASCII Output Codes
01–7F 80–A6 A7–CD CE–F4
01 \n\ 80 \0\ A7 \ograve\ CE \...\
02 \u\ 81 \1\ A8 \ocirc\ CF \<\
03 \v\ 82 \2\ A9 \ouml\ D0 \block\
04 \w\ 83 \3\ AA \Uacute\ D1 \per\
05 \>\ 84 \4\ AB \Ugrave\ D2 \-\
06 \squp\ 85 \5\ AC \Ucirc\ D3 \area\
07 \sqdown\ 86 \6\ AD \Uuml\ D4 \^box\
08 \intgrl\ 87 \7\ AE \uacute\ D5 \^3\
09 \x\ 88 \8\ AF \ugrave\ D6 \enter\
0A \box\ 89 \9\ B0 \ucirc\ D7 \i\
0B \cross\ 8A \Aacute\ B1 \uuml\ D8 \p^\
0C \dot\ 8B \Agrave\ B2 \Ccedil\ D9 \chi\
0D \subT\ 8C \Acirc\ B3 \ccedil\ DA \statF\
0E \root3\ 8D \Auml\ B4 \Ntilde\ DB \e\
0F \hexF\ 8E \aacute\ B5 \ntilde\ DC \L\
10 \root\ 8F \agrave\ B6 \acute\ DD \N\
11 \^-1\ 90 \acirc\ DE \))\
12 \^2\ 91 \auml\ B8 \..\ DF \blk->\
13 \/_\ 92 \Eacute\ B9 \iquest\ E0 \cursor\
14 \o\ 93 \Egrave\ BA \iexcl\ E1 \2ndcur\
15 \r\ 94 \Ecirc\ BB \alpha\ E2 \Acur\
16 \^T\ 95 \Euml\ BC \beta\ E3 \acur\
17 \<=\ 96 \eacute\ BD \gamma\ E4 \inscur\
18 \!=\ 97 \egrave\ BE \Delta\ E5 \ins2nd\
19 \>=\ 98 \ecirc\ BF \delta\ E6 \ins_A\
1A \(-)\ 99 \euml\ C0 \epsil\ E7 \ins_a\
1B \EE\ 9A \Iacute\ E8 \gline1\
1C \->\ 9B \Igrave\ C2 \Lambda\ E9 \gline2\
1D \10\ 9C \Icirc\ C3 \mu\ EA \gabove\
1E \uarrow\ 9D \Iuml\ C4 \pi\ EB \gbelow\
1F \darrow\ 9E \iacute\ C5 \rho\ EC \gpath\
9F \igrave\ C6 \Sigma\ ED \ganim\
24 \^4\ A0 \icirc\ C7 \sigma\ EE \gdot\
A1 \iuml\ C8 \tau\ EF \upblk\
5B \theta\ A2 \Oacute\ C9 \phi\ F0 \dnblk\
A3 \Ograve\ CA \Omega\ F1 \chkrbd\
60 \lsquo\ A4 \Ocirc\ CB \xbar\
A5 \Ouml\ CC \ybar\ F3 \squp_2\
7F \=\ A6 \oacute\ CD \^x\ F4 \szlig\

Program Summary

A quality version of the classic pipes game.

Program Size

5,276 bytes

Uses Libraries?

No, it's pure TI-Basic

Calculator Compatibility

TI-83/84/+/SE

Author

Sean Sartell (staind234)

Download

pipes.zip

Pipes is an action / puzzle game that involves connecting pieces of pipe to the single piece of pipe that you start out with, with the goal of trying to make one continuous pipe so that the water doesn't reach the end. You are given a set amount of time to assemble the pipe before the water is unleashed, and because the pipe pieces are randomly generated, you need to use that time wisely.

Each round you have a set number of points that you need to reach with the water flowing in the pipe, and if you don't reach that point total, the game is over. If you were able to survive long enough, you might have qualified for a high score.

The game runs strictly on the graph screen, and features a nice graphical interface, title screen, and menu, as well keeping track of the top five high scores. Of course, the main feature of the game is that it provides almost unlimited gameplay, since the pieces are randomly generated and the rounds keep going until you lose. The standard controls are used: 2nd to make a selection and arrow keys to move.

Program Summary

A quality version of the classic dstar game.

Program Size

4,800 bytes

Uses Libraries?

No, it's pure TI-Basic

Calculator Compatibility

TI-83/84/+/SE

Author

Scott Davis

Download

dstar.zip

DStar is a fun puzzle game that involves moving around a + sign and a box to collect all five of the pieces in the fewest moves possible. While that sounds easy, the + sign always moves until it gets to a wall, so you have to be very methodical in planning how to collect the pieces (i.e., you need to use the box to get the necessary positioning). Also note that you can swap the + sign and the box, but that counts as a move as well.

The game features several built-in levels that you can play, but it also has support for a level editor and external levels. Using the level editor is a breeze — you just press the appropriate F# keys to add or remove the walls, + sign, box, and pieces, and then press ENTER when you are done to save it. In addition, the game also allows you to save and load, which means you can save your progress without worrying about it being deleted.

Like most of the other dstar clones, this version runs strictly on the graph screen, and features a nice graphical interface. The game uses the standard controls: the arrow keys move the + around, ALPHA starts the level over again, TRACE saves the game, GRAPH loads the game, and DEL exits the game.

Program Summary

A quality version of the classic lights out game.

Program Size

3,400 bytes

Uses Libraries?

No, it's pure TI-Basic

Calculator Compatibility

TI-83/84/+/SE

Author

Scott Davis

Download

lightsout.zip

Lights Out is a fun puzzle game that involves trying to turn off all of the lights. While that sounds easy, when you select a square it inverts not only the square itself, but the four squares surrounding it (i.e., if a square is on, it will be turned off, and vice versa).

The game features three different modes of play — normal, random, and custom — which means it will be staying on your calculator for a while until you beat it. Speaking of which, when you win the game, you get a nice win sequence that is reminiscent of the classic Tiger handheld version.

Unlike some of the other lights out clones, this version runs strictly on the graph screen, and features a nice graphical interface. The game uses the standard controls: the arrow keys move the cursor, while 2nd/ENTER makes a selection in the menu and on the game board.

Program Summary

A quality version of the classic metroid game.

Program Size

17KB

Uses Libraries?

No, it's pure TI-Basic

Calculator Compatibility

TI-83/84/+/SE

Author

Robert Moy (Harrierfalcon)

Download

metroidpi.zip

Metroid Pi is a pure TI-Basic version of the classic Metroid game, with the game following the standard storyline of making your way through several increasingly difficult areas, while battling enemies, bosses, and getting powerups that allow you to beat the next area in the game. The game utilizes the graph screen throughout, making use of the layered graphics technique that Super Speler came up with in his Zoith game, but the sprites themselves are still reminiscent of the home screen text.

Of course, none of this is cheap in the memory department. The game takes up over 17KB, with it spread out over seventeen different programs (in particular, each of the three bosses and three maps are given their own program), and you need to have each of these files unarchived in order to actually play the game. Of course, this does not include the actual in game usage that occurs from using all of the lists, strings, and real variables, which is another 5KB of memory.

Still, the game is a great achievement in TI-Basic, and surely stretches what people thought is possible.

Program Summary

A quality version of the classic sudoku game.

Program Size

4,051 bytes

Uses Libraries?

No, it's pure TI-Basic

Calculator Compatibility

TI-83/84/+/SE

Author

Harrierfalcon

Download

sudoku.zip

Sudoku is a puzzle game that involves filling a 9x9 grid so that each column, each row, and each of the nine 3x3 boxes contains the digits 1 to 9 only one time. You start out with a partially filled grid with each 3x3 box containing anywhere from one to five numbers, and you then have to fill in the rest.

This sudoku games comes not only with five pre-solved sudokus, but it also has support for creating randomly generated sudokus. Unlike some other sudoku games that simply change the arrangement of the numbers, which isn't really random at all, this game actually creates totally new sudokus by swapping the rows of existing sudokus.

The game features a good graphical interface, with easy to use controls. It does, however, use a considerable number of variables, including five matrices, the majority of the real variables, all six of the built-in lists, and a string. This means you have to make sure you don't have anything in those variables, since it will be erased.

Program Summary

A quality version of the classic number slider game.

Program Size

1,574 bytes

Uses Libraries?

No, it's pure TI-Basic

Calculator Compatibility

TI-83/84/+/SE

Author

XprO

Download

xmove15.zip

Xmove15 is a small, but fun puzzle game that involves moving numbers around a 4x4 board until you get them in the order 1 to 15 (with the numbers wrapping from the right edge to the left edge on the next row). You control a cursor that you use to move the numbers: put the cursor over a number next to the empty spot, and the number and the empty spot will be swapped when you press 2nd.

Just like with XprO's other quality game, Xsnake, Xmove15 features great TI-Basic code. The game makes ample use of control structures, with a very easy to follow organization and setup, as well as showcasing several optimizations for speed and size. Simply put, it is a lot of fun to look at the underlying code, and to see what is possible in a small number of bytes.

Program Summary

A quality version of the classic snake game.

Program Size

1,468 bytes

Uses Libraries?

No, it's pure TI-Basic

Calculator Compatibility

TI-83/84/+/SE

Author

XprO

Download

xsnake.zip

Xsnake is one of those rare TI-Basic games that not only are fun to play, but also fun to look at the underlying code. The game is written entirely in TI-Basic, but it is as fast as the assembly snake counterparts — in fact, it is the fastest TI-Basic snake game available.

The main innovation that allowed Xsnake to be so fast is that the four arrow directions are each split up into their own separate loop, which cuts down on If conditionals and other speed impediments. The game also uses the pxl-Test( command for collision detection, which is faster than accessing a variable (like most other snake games do).

In terms of gameplay, Xsnake features the standard goal: you go around eating food, but each piece of food makes the snake grow longer. The game comes with seven built-in levels of increasing difficulty that you need to make your way through to beat the game, and you have to do it with only three lives.

The game uses the standard controls: 2nd/ENTER to pause in the game, CLEAR to quit, and the arrow keys move the snake in the respective direction. The graphics are not sophisticated by any measure, but that isn't really the focus of the game anyway.

The featured articles are articles that represent the best TI-Basic Developer has to offer. A featured article meets all of the following requirements:

• Well-Written — It is easy to read, flows smoothly, and does not have any spelling or grammatical errors.
• Complete — It includes everything about the topic, including theory, code examples, and screenshots, when appropriate.
• References — If applicable, it lists the sources that were used in putting together the article.

To nominate an article for being featured, add it to the list below.

# Featured Articles

The ListPages module does not work recursively.

Did you know…

The ListPages module does not work recursively.

{$part1begin} To add an article, move the current featured article from {$part2} to {$part3}, and add a new featured article to {$part2}. See the featured articles page to view the data on this page in a cosmetic format.

{$part1end} {$part2begin}

"Sprites" are small images displayed as part of a larger scene on the screen. In TI-68k Basic, support for sprites is built-in, in the form of picture variables.

The most common reasons to use a sprite are to display a picture which will be moved around on the screen, or repeated multiple times as part of a pattern (more...)

{$part2end} {$part3begin}

"Tokenization" is the process whereby the characters that make up a command are replaced by a token — a number representing the command.

Since the size of the program is determined by its tokenized size, understanding this process is key to optimization, at least for size. (more...)

{$part3end} {$part1begin}

To add a DYK, move the second DYK from {$part2} to {$part3}, and add a new DYK to {$part2}. See the Did You Know... Archives page to view the data on this page in a cosmetic format. {$part1end}
{$part2begin} …that displaying sprites to column coordinates divisible by 8 is faster than to other coordinates? …that setmode() and similar commands have an alternate "programmer's syntax"? …that strings are the fastest data type to access, given enough elements? {$part2end}
{$part3begin} …that the ok system variable checks if a dialog was cancelled? …that the 26 one-letter variables a-z are much smaller to access? …that the © character can be used to enter comments in programs? …that ending a variable name with an underscore _ will make solve() and cSolve() assume it's complex? …that you can treat strings as always-undefined variables in symbolic math? {$part3end}

{$part1begin} To add any news, move the fifth news item from {$part3} to {$part4}, and add a new news item to {$part3}. The date format is day/month.

See the News Archive page to view the data on this page in a cosmetic format.

{$part1end} {$part2begin}

# 2008

{$part2end} {$part3begin}
04/09burr, the founder of the site, has finished contributing to the site, and moved on to other projects. (see his goodbye here)
01/09 — TI-Basic Developer has now existed for approximately two years. Thanks to all that made it a great year, and may the next year be even more successful and exciting.
11/06James Kanjo created a "New Members" section on the home page
18/05 — The development of the TI|BD site logo is complete, and has now replaced the previous site header.
15/05James Kanjo has set up a new framework for infoboxes.
{$part3end} {$part4begin}
04/05krazyness initiated the development of the TI|BD site logo, to replace the current header.
02/04 — The home page has been updated to automatically retrieve text for news, "did-you-know" tips, and featured articles.
02/04James Kanjo made the Start page automatically retrieve the first 5 news items from the old news section.
30/03burr started the downloads page, and added all of the 68k tutorials that he found on the Internet.
13/03DarkerLine added include pages which make adding a new command page much easier. Go for it!
08/02DarkerLine started a tokenization page, detailing what tokenization is and how it impacts program size and optimization.
02/02DarkerLine put together a calculators page, which provides a brief, but detailed look at the different calculators and their specifications.
01/02DarkerLine started the key codes page, as well as the character codes page.
31/01burr created 68k versions of all of the relevant system pages, which will hopefully minimize any ambiguity or uncertainty about where you are on the site.
31/01DarkerLine added an errors page that lists all of the possible error messages that can occur, including the error numbers and their descriptions.
29/01DarkerLine begins work on this section of the site, creating the homepage, top navigation, command stub and the command index.
{$part4end} {$part1begin}

To add any news, move the fifth news item from {$part3} to {$part4}, and add a new news item to {$part3}. The date format is day/month. See the News Archive page to view the data on this page in a cosmetic format. {$part1end}
{$part2begin} # 2008 {$part2end}
{$part3begin} 03/10James Kanjo made a new Did You Know… system, where each DYK has it's own page in the dyk category. Now the DYK on the home page sidebar displays a randomly selected DYK. 01/10James Kanjo added a choose a "random command" link to the sidebar…COOL! 27/09Timothy Foster created the page TI-Nspire Programming. 15/09James Kanjo upgraded the framework of the TI|BD archives. Now it is even easier to add, update, rate and moderate programs! 04/09burr, the founder of the site, has finished contributing to the site, and moved on to other projects. (see his goodbye here) {$part3end}
{$part4begin} 04/09James Kanjo tagged the 25 remaining untagged "redirect" pages 04/09basickevin created the page artificial intelligence 03/09RandomProductions created the page How the Calculator Works. 01/09 — TI-Basic Developer has now existed for approximately two years. Thanks to all that made it a great year, and may the next year be even more successful and exciting. 28/07burr did some reorganization and cleanup to the resources page. 14/07Zaphod Beeblebrox created the page Text Sprites Reference 08/07basickevin created the page alternate routines to promote the creation of new optimizations 03/07burr and James Kanjo set up the framework for the new TI|BD archives 01/07Mapar007 created the page Binary and Hexadecimal number system 20/06Zaphod Beeblebrox changed the resources page to use the tabview 13/06James Kanjo added an "Instant Messenger" routine to the programs page 11/06James Kanjo created a "New Members" section on the home page 06/06James Kanjo finished integrating the new infobox framework into all 324 command pages 02/06burr updated the showcases page separating the programs by genre and using the tabview. 24/05RandomProductions spruced up the user input page to be a bit more recent. 18/05 — The development of the TI|BD site logo is complete, and has now replaced the previous site header. 10/05James Kanjo has set up a new framework for infoboxes. 04/05krazyness initiated the development of the TI|BD site logo, to replace the current header. 24/04DarkerLine has finished the first chapter of the Starter Kit, a tutorial for beginner programmers. 23/04burr created a validation tutorial that covers how to approach validating user input. 16/04burr added a file download to all of the routines and programs. 12/04burr created a TI-Basic Sidebar for Mozilla Firefox for quick reference of the TI-83 commands when you are away from the site. 02/04DarkerLine, Socks and James Kanjo worked together to upgrade the implemented "include template" sections of the site. Result: Site automatically retrieves the required parts of the "Recent News", "Did You Know" and "Featured Article" sections for the home page. 02/04James Kanjo made the Start page automatically retrieve the first 5 news items from the old news section. 30/03burr started the Featured Articles page that lists the best articles available on the wiki, along with changing the "Featured Article" section in the sidebar on the homepage into an include page. 27/03burr started a Did You Know... page with a list of premade DYK's, along with changing the "Did You Know…" section in the sidebar into an include page. 25/03James Kanjo added a warning to the grouping section, which the TI-Basic community may have previously been unaware of. 16/03Weregoose created two pages on the calculator's internal fonts. DarkerLine has already found these images useful on other pages. 08/03Socks started working on the TI-Basic Starter Kit. Feel free to contribute. 23/02RandomProductions put screenshots on all of the date and time command pages. 09/02burr created a portal page, which acts as a bridge between the TI-83 and 68k sections of the site, and is now the new homepage for the site. 29/01DarkerLine begins work on the 68k section of the site. 29/01 — All commands have now been documented! Woo! 26/01burr added an optimization walkthrough tutorial which takes a person through the literal process of optimizing a game. 24/01DarkerLine broke up the text manipulation page into a few routine pages: highlighting text, wordwrapping text and marquee. 09/01 — The zoom commands have been documented, finishing up all commands except for the finance ones. # 2007 16/12 — The xLIB Guru has merged with this wiki, and its content has been added. 13/12 — The page about user settings, along with its various subpages, is now complete. 11/12burr created a Boolean logic page detailing what Boolean logic is and how you can use it in your programs. 27/11DarkerLine finished writing the pages about the various variable types, and started on the settings commands. 24/11simplethinker started creating pages for the trigonometry and polar functions. 22/11burr added tags to the majority of the pages; only the command pages are left. 18/11DarkerLine started creating pages for the different variable commands. 16/11DarkerLine finished creating pages for the individual math commands. 06/11burr created a self-modifying code page explaining what self-modifying code is and how you can use it. 18/10burr began to create individual routines pages, using the new routine template 15/10alexrudd began to split up the math page into separate command pages. 14/10burr created a downloads page with over 100 zip files to download. 01/09 — TI-Basic Developer has now existed for approximately a year. May the next year be even more successful and exciting. 26/07burr put together a Frequently Asked Questions (FAQ) list of common TI-Basic related questions that people ask. 24/07burr made a Sitemap that has a hierarchical breakdown of the site for easy viewing. 22/07burr started a Common Coding Pitfalls page, which lists several different examples of code that are syntactically correct, but do not produce the correct or desired results. 01/07burr started a Code of Conduct page, which lays down some general conduct rules to follow when contributing to the wiki. 27/06burr started a Glossary page, which has general definitions for several of the words that are used throughout the wiki. 26/06burr created a Code Commenting page, which is extremely useful for those people who are working on multiple projects at the same time, and want to be able to come back to a project without all the stress of figuring out what everything is again. 23/06burr finished updating the Subprograms page, so now the external and internal subprograms are explained in comprehensive detail. 22/06Xphoenix added a general section to the Program Setup page, and also created two pages: Assembly Shells and Basic Builder. 22/06burr started a Program Setup page in the same fashion as the Program Cleanup page. Program setup includes getting the home screen, graph screen, and variables ready so your program can use them. 18/06DarkerLine finally finished the Statistics pages. He's going to go back and add complicated formulas no one understands sometime later. 13/06DarkerLine started working on the Statistics pages like he said he was going to a month ago… 03/06Xphoenix created pages for some of the Graph Screen commands. 05/05Harrierfalcon optimized one of the examples on the Compression Techniques page by using the seq( command. 30/04alexrudd added the xor and not( operators to the Logical Operators page. 22/04burr started the Project Challenges page. After you have gone through the wiki and learned the commands, design theory, and game techniques, you can now test yourself and try your hand at making some programs. 21/04burr started the Old News page, which is the archive place for all the old news and is kept for posterity sake. 19/04 — A few more games have been added to the Programs page, including: Avalanche, Maze Walkthrough, Pong, and Tic-Tac-To. The programs are all available for download in case anyone wants to try them out on their calculator. 15/04burr added a Wiki Conventions page that lays down some general guidelines about how to format page content. There's a similar Command Stub page for command pages. 13/04thornahawk and Xphoenix added some more information about the Math commands. 08/04burr started the Review Exercises page, which allows readers to test their comprehension and understanding of the information on the wiki. 30/03 — The Wiki Tour was started, providing a general overview of the wiki and giving beginners some direction about using the wiki. 26/03alexrudd began experimenting with internal page anchors, and has decided that we should try to integrate them into more pages. 25/03DarkerLine started working on the Statistics Commands. These commands are extremely useful for anybody who has to take a statistics class. 23/03burr updated the Contribute page with some guidelines to help beginners better use the wiki. 15/03Harrierfalcon added Number Functionality to Custom Text Input. 03/03burr started the Recursion page. Recursion is related to using subprograms to optimize a program, except the program calls itself instead of other programs. 21/02DarkerLine decided we should give each command its own individual page, so that all the relevant information about that command can be put on one page. Be sure to check out the Command Stub to see how the information is organized. 19/02burr started the Usability page. It offers some ideas to think about when designing a program, including preventing the user from hurting themselves and following the KISS principle. 16/02alexrudd started a Deck of Cards page that should be helpful to anyone who is wanting to learn how to manage the cards in a card game (such as Blackjack). # 2006 08/11alexrudd and DarkerLine are promoted to admins, so they are now able to do all of the admin-related things for the wiki. 14/10burr started the Marketing page. It offers some solid suggestions on ways to market your programs to the community. 10/10burr started the Writing Program Documentation page. Check it out if you are wondering why documentation is important and what things your program documentation should include. 07/10 — Talks of merging the wiki with the Function Library forum occur, but they ultimately fall through because it is decided that the wiki already covers much of the same content and the forum quality isn't very good. 06/10burr started the Look-Up Tables page. Look-up tables are commonly used to increase the speed of programs when speed is the primary need in the program. This is especially true if graphics or user input are involved. 24/09burr started the Custom Text Input page. It shows a simple input routine, briefly explaining how custom text input works and how you can expand the functionality to suit your own purposes and needs. 23/09alexrudd updated the Program Protection page, further refining the different ways to protect a program. In addition, some good discussion about program protection and whether it is appropriate occurred over at the UTI TI-Basic forum. 23/09burr started the Program Clean Up page. After a program finishes running, it should clean up after itself. This involves restoring the respective screens, deleting variables, and some other things. 22/09burr started the Optimizations page. The page details the many different optimizations that you can do to a program, organizing them into relevant and related categories. 06/09 — The wiki is moved from Wikispaces to Wikidot for hosting because the look of the pages and editor is better, and it offers a lot more space for the wiki to grow and mature. 01/09 — TI-Basic Developer wiki is started by burr using the content from his TI-Basic Developer guide as the foundation for the wiki. {$part4end}

Program Summary

A quality version of the classic lode runner game.

Program Size

3,000 bytes

Uses Libraries?

No, it's pure TI-Basic

Calculator Compatibility

TI-83/84/+/SE

Author

SiCoDe (Brandon Green & Tim Parkin)

Download

loderunner.zip

Lode Runner is a classic puzzle game that involves collecting all of the coins a level by navigating through the ladders and platforms, as well as avoiding the enemies. This is the only TI-83 Basic lode runner game available, but it is a quality game nonetheless.

Like with some of the other popular SiCoDe games, this game utilizes the home screen scrolling made possible by the Output( command to display the levels. The Output( command has wordwrapping functionality built-in, in which any text that goes over the 16 characters of a row will be wrapped to the next row (and likewise with that row), and subsequently you can use a single Output( command to display an entire screen of text.

This functionality not only allows the text to be displayed very quickly — in fact, there is no faster way to display text in TI-Basic — but also very efficiently. What people were doing previously was actually just using several Output( commands, and then displaying each row of the screen separately. Obviously, this approach does not lend itself to making fast games, and so most games were rather slow.

The game uses the standard controls: arrow keys to move, CLEAR to quit, 2nd/ENTER to pause, along with MODE to make a hole in the ground to the left of the player and DEL to make a hole to the right. There are ten built-in levels, but the game also has support for external levels (what SiCoDe refers to as expansion sets).

The featured articles are articles that represent the best TI-Basic Developer has to offer. A featured article meets all of the following requirements:

• Well-Written — It is easy to read, flows smoothly, and does not have any spelling or grammatical errors.
• Complete — It includes everything about the topic, including theory, code examples, and screenshots, when appropriate.
• References — If applicable, it lists the sources that were used in putting together the article.

To nominate an article for being featured, add it to the list below.

# Featured Articles

The ListPages module does not work recursively.

{$part1begin} To add an article, move the current featured article from {$part2} to {$part3}, and add a new featured article to {$part2}. See the featured articles page to view the data on this page in a cosmetic format.

{$part1end} {$part2begin}

When it comes to releasing a program, an inexperienced programmer may well release his work quietly and in an unassuming form, which people will simply glance over without stopping.

This tutorial will tell you how to avoid this, and make your program get all the attention it deserves. (more...)

{$part2end} {$part3begin}

Piecewise expressions are a shortcut to handling conditions in math statements.

They can be used for turning an If block or several such blocks into a single line, creating much smaller and faster code. (more...)

A subprogram is a program called by another program to perform a particular task or function for the program.

When a task needs to be performed multiple times (such as displaying character data), you can make it into a separate subprogram.

The complete program is thus made up of multiple smaller, independent subprograms that work together with the main program. (more...)

Statistics is a mathematical science pertaining to the collection, analysis, interpretation or explanation, and presentation of data (source: Wikipedia).

The calculator has a series of commands devoted to statistics, including regression models, probability distributions, significance tests, and confidence intervals (more...)

Optimization is an extremely important part of the programming process, and involves making programs as fast and small as possible. Speed is important because TI-Basic is slow, while size is important because the calculator has limited memory.

It should be your goal, in virtually all cases, to make your programs as small and fast as possible. (more...)

{$part3end} These tools will help you to interact more with your 68k calculator. It's the goal of this site to eventually cover all information on TI-Basic programming for the 68k calculators. However, an excess of information can be overwhelming. So this page gives a suggested reading order (as well as necessary tidbits) so you don't get lost. # For Beginners There are two alternatives for those who have just ventured into programming for these calculators. While you might want to just jump in, we have two tutorials that explain the basics of TI-Basic. The first, the TI-Basic Starter Kit, teaches TI-Basic without assuming any previous programming experience. In fact, the very first page explains the basics of how a program works. After reading this tutorial carefully, you should be more than ready to handle the rest of this site. The second tutorial is called TI-68k Programming for TI-83 Coders. As the name suggests, it is an introduction to programming for the 68k calculators, for those who have already gotten pretty good at programming for the TI-83 series calculators. This is a fairly common situation: often, people get a new calculator when taking a more advanced math class. This tutorial explains the differences between TI-83 and TI-68k programming, so that you're not confused by the new features. # Further Reading At this point, you should be familiar with more than a few TI-Basic commands. It might be a good idea to just jump into the command index and click on commands that sound interesting — you can really improve your TI-Basic knowledge that way. Or, select a category from the Commands menu in the top navigation, and read about commands in a more general way. Looking at code examples is also a good way to learn. Sample Programs and Technique Examples are a good place to find such example code. See the Routines page for several short routines to get simple things done in the best possible way. Use the glossary whenever you come across a term you're not familiar with. If it's not there or the entry doesn't help, drop a note in the forums and (usually within a day) helpful people will explain it and hopefully improve the glossary as well, so no one else has the same trouble. # Writing a Program Of course, the best way to learn these topics is to come up with a project of yourself (check the projects page if you have no ideas), and go through the steps as you're doing it: 1. Look at Planning when you're thinking about how to approach the problem. 2. Consider Commenting code when you're writing it. 3. If bugs arise (and they most likely will), see the section on Debugging. 4. When the program works, add Setup and Cleanup to it, and check the section on Usability. 5. If the program is too slow (and maybe even when it's not), see Optimization and Code Timings for ways to improve it. 6. Finally, see Releasing Your Program for how to earn TI-Basic programming fame by making the program public. These are listed in the Writing Programs section of the side navigation menu. # Advanced Topics The "Special Topics" section (in the side navigation menu) discusses some advanced issues in TI-68k programming. You should probably have a good grasp of programming before venturing into these pages, but they are worth reading. Give them a glance to see how much you can understand. Each special topic is mostly a stand-alone page. Here are the relative difficulties of the pages: ### Easy • Subprograms — an idea you should be familiar with by now. • Saving Data — almost as easy as just storing to a variable. • Assembly — I'm not saying writing assembly is easy, but learning about it sure is. ### Intermediate • Sprites — a matter of learning several commands, and where to use them. • Animation — a natural second step from the above. • Dialogs — again, just learning a few commands. ### Hard • Compression — if you wanted, you could get into some heavy theory with this. • System Variables — almost more useful as a reference tool than anything else. • Tokenization — not much practical use, but it's useful to understand how things work. • Cross-Compatibility — if only more people were aware of this… # Reference Material The pages in the Reference section of the side menu are probably not ones you'd read for fun. Take a look at them at any time to see what they're all about, and then check back when you need to know more. Now that you have learned the commands, design theory and game techniques, it's time to put that information to use. These project ideas are for programs that you should try to make to the given specifications, using whatever commands you need. Of course, the specifications aren't set in stone, so you don't have to include something if you don't want to. In addition to following the specifications, try to make the programs as optimized as possible, and use good design when structuring them (i.e., don't use Goto when a loop is really what you should be using). If you can successfully make all of these programs, and have done a good job writing them, you can consider yourself a good programmer. If you are having trouble making any of the programs, or you just want some input from other people, you can post in the forum. Before you do that, though, we encourage you to really try to create the programs and put some thought into them. ## Phone Directory Create a phone directory with these features: • Make a list of phone numbers, and also include the person(s) who own the phone number. • Display the phone numbers and person(s) on the screen. • Let the user sort through the phone numbers in ascending and descending order. • Let the user create, delete, and update the phone numbers and person(s). ## Role-Playing Game (RPG) Create an RPG with these features: • Use the graph screen for the interface. • Split the map into multiple pieces, displaying each piece when needed. • Create a theme for the RPG and base everything off of it. • Give the player a few weapons to attack enemies with. • Create AI enemies that the player can battle for experience points. • Make a couple bosses that the player has to defeat to adavance to the next level. • Upgrade the player weapons when set experience points are gained. ## Snake Create a snake game with these features: • Make a snake character that you can move around on the screen using the arrow keys. • Randomly display a piece of food on the screen for the snake to "eat". • Use collision detection to check if the food was eaten or the snake went off the screen. • If the snake goes over the screen boundaries, the snake is dead and the game is over. • Keep a highscore based on the highest amount of food the snake has eaten at one time. ## BlackJack Create a blackjack game with these features: • Use a graphical interface. • Have custom input for both players, alternating between players. • Implement all the rules of blackjack into the game. • Record the games won/lost by each player. ## Hangman Create a hangman game with these features: • Use a graphical interface. • Use custom input for both players. • Have one player choose a word, and the other player guess the word. • The guessing player gets ten chances to guess the word before they lose. • The guessing player selects a letter that they think is in the word. If the letter is there, then that letter is revealed and the player doesn't lose a chance. • If the letter is not there, the player loses one of their chances. • If the player guesses all the letters in the word, they win. If they run out of chances before they get the word, they lose. The programs linked from this page are short programs meant to demonstrate the use of several programming techniques described elsewhere in this guide. For readers who learn better by example than by explanation, these programs are a great way to learn these techniques. These programs have been fully optimized, except where this would interfere with readability. For example, the names of variables could easily be converted to single characters — this was deliberately left undone. The individual pages explain what would be done to finish the job of optimization. A | B | C | D | E | F | G | H | I | K | L | M | N | O | P | R | S | T | U | V ## A Argument One of the values that a command acts on. Array A collection of numeric variables arranged in a list or matrix for processing by the calculator. Each element in an array is referenced by its index - position in the array. ASCII The American Standard Code of Information Interchange. It uses 1 byte (8 bits) to hold a character, and thus is limited to 256 different characters. The calculator uses a modified version of ASCII internally to store characters (see Character Codes), but the TI-Basic interpreter deals with tokens instead. Assembly The other programming language built-in to the TI graphing calculators, apart from TI-Basic. It is much more difficult to learn and program in, but at the same time it is much more powerful, and can be used to create very sophisticated games and programs. You can also compile C into an assembly program. ## B Binary The two-digit (bit) number system based on 0 and 1, similar to the way the normal decimal system is based on the numbers 0-9. For example the number 10101 in binary represents 1*24+0*23+1*22+0*2+1, or 21 in decimal. To enter a number in binary on a TI-68k calculator, write 0b followed by the number. Bit A binary digit (0 or 1). Branch A departure from the sequential performance of program statements. An unconditional branch causes the calculator to jump to a specified place in the program each time the branching statement is encountered. A conditional branch transfers program control based on the result of some logical condition. Breakpoint A point in a program where program execution can be suspended, used when debugging the program. In TI-Basic, such breakpoints can be created with the Text command. Bug An error in a program (see also Debugging). Byte A string of eight bits. The calculator uses one byte of information to encode the letter "A", as well as most tokens. Bytes (or kilobytes - one kilobyte is 1024 bytes) are used to measure the amount of memory a program or variable takes up on the calculator. ## C C A popular programming language on many platforms. Using TIGCC, C programs can be compiled to assembly for the TI-68k calculators. Character A letter, number, punctuation symbol, or special graphics symbol. They are encoded in ASCII format internally, but the TI-Basic interpreter uses tokens instead. Clock cycle The unit of time in a CPU. It is so small that even the most primitive assembly instructions take several clock cycles to run; the amount of clock cycles it takes for a single TI-Basic command can be in the millions. Command A word or token that tells the calculator to do something. Examples: RclPic, For, max(), etc. They are sometimes subdivided into functions and instructions Concatenation Joining two or more strings together to make a longer string. The ampersand — & — is the concatenation operator. For example, "TI-"&"Basic"="TI-Basic". Condition A logical expression that the calculator can evaluate to be true or false. Constant A specific number, list, matrix, or string that is given as a fixed value in the program (such as 9.024 or "Hello"), rather than contained in a variable. CPU (Central Processing Unit) The "brain" of the calculator, where the calculator controls the processing and execution of everything. Cursor A small, flashing square showing where a typed character will appear. A cursor (in the form of a crosshair) is also used on the graph screen to input a point from the user. ## D Data Information, often numerical in form. When data is used by a calculator program, it can be hardcoded or softcoded. Debugging Fixing a program to remove bugs, or mistakes. There are many techniques for debugging, some universal, some specific to calculator programming. Decimal A base 10 number system using the symbols 0-9. It is the default number system used by the calculator. Default A standard characteristic or value which the calculator assumes without specification. For example, the RclPic displays a picture at the coordinate (0,0) by default (the top left corner). This can be overwritten with further arguments to specify the coordinate to display at. Dialog A message box displayed on the screen for input and output. ## E Execute Another name for running a program or command. Exponent A number indicating the power to which a number or expression is to be raised, usually written at the right and above the number. For example, 26 = 2x2x2x2x2x2. In scientific notation, the power of ten which the mantissa is multiplied by to calculate the actual number. ## F Flash The ROM/archive memory on the TI-68k calculators where applications are stored. Floating point The format used in TI-Basic for storing decimals. It uses scientific notation to display all numbers. Flow Chart A diagram of geometric shapes connected by arrows that show the progression of a program. Flow charts are handy for developing complicated programs and illustrating how programs work. Function The word Function has several meanings in the context of TI-Basic programming. It can mean a type of command that returns a value - such as gcd() or sin(). Or it can mean a type of user-defined program that returns a value. ## G Graphics Any sort of visual display on the screen, such as graphs, patters, and drawings, both stationary and animated. ## H Hardcode Hardcoded data is information used by the program that results from the logic of its commands. It is very easy for the program to read, but can be impossible to change. Hardware The circuit boards and other electronic parts which make up a calculator. Hexadecimal A base 16 number system using 16 symbols, 0-9 and A-F. It is used as a convenient shorthand way to express binary code, because every four bits of binary have a corresponding hexadecimal symbol. To enter a number in hexadecimal on a TI-68k calculator, write 0h followed by the number. ## I Index A position in an array. In TI-Basic, arrays are indexed starting with 1 (so that the first element in a list is numbered 1, the second 2, and so on). In some other languages, they are indexed starting with 0. Input The means by which data is entered into the calculator by the user, primarily through the calculator's keys (though the link port is also a form of input). Instruction In the case of TI-Basic programming, this is often used to indicate a type of command that does not return a value, but stands alone: for example, Line, or Input. It is also sometimes used to describe commands in general. Integer A whole number, positive or negative (or 0). Usually in TI-Basic, a number is an integer by default, which means all of its digits are stored exactly. You can also use floating point numbers for approximate calculations with decimals. Interpreter The algorithm stored inside the calculator that runs a TI-Basic program by executing the appropriate system routines. Iteration One repetition of a loop. For certain commands, the calculator has an internal loop for which the total number of iterations is relevant, and affects accuracy. ## K Keypad The panel of keys used to enter programs and data into the calculator. ## L List A sequence of variables which can be accessed and modified by their position. In TI-Basic, lists can have any mix of variable types. Loop A group of one or more consecutive program lines which are performed repeatedly, either a specific number of times, or until a condition is met. ## M Mantissa The basic numeric portion of a number expressed in scientific notation. In 3.264E + 4, the mantissa is 3.264. Matrix A two-dimensional grid of variables which can be accessed and modified by their position. In TI-Basic, lists can have any mix of variable types. Memory The two different places (RAM and ROM) where calculator programs and data are stored. All variables and programs take up part of memory to store, which makes the size of a program or variable very important. MHz The speed the calculator CPU runs at. It ranges from 10MHz to 16MHz on the TI-68k calculators. It's measured in millions of clock cycles per second. ## N Number system A way of writing down a number. Two common systems used by people are the decimal (Arabic) system, and the Roman numeral system. The calculator uses the binary system internally, but the decimal system is what it usually displays. ## O Operator A symbol used in calculations (numeric operators) or in relationship comparisons (related operations). The math operators are +, -, *, /, ^. The relational operators are >, <, =, ≥, ≤, ≠. The logic operators are and, or, xor, not. Optimization The process of improving the running time, length, or memory usage of a program. Output Information sent from the calculator, e.g. graphics on the screen. Also, the means by which data leaves the calculator, through either the link cable, graph link, or USB cable. OS (Operating System) The internal program that runs the calculator and includes all the functionality needed to use the calculator. ## P Program The list of instructions that tells the calculator what to do to perform a task. Programmer A person who writes programs. Programming Language Numeric or alphabetic commands which the calculator can understand, and execute. ## R RAM (Random Access Memory) A temporary memory, i.e. one in which data is stored so long as electrical power is applied. Data in RAM can be accessed or changed and is lost if the batteries are removed from the calculator. Recursion A program that calls itself as a subroutine (or a function that's defined in terms of itself). See recursion. ROM (Read Only Memory) Certain instructions for the calculator are permanently stored in ROM and can be accessed but cannot be changed. Data in ROM is not lost if batteries are removed. ## S Scientific Notation A method of expressing very large or very small numbers by using a base number (mantissa) times ten raised to some power (exponent). Scroll Shifting part of the screen to give the illusion of seeing only part of an image larger than the screen. Softcode Softcoded data is information stored in an array at the beginning of the program, and read from it later. It is usually slower to read than hardcoded data, but the advantage is that the same code can often used for different data stored in the same way. Sprite A small image which is moved around the screen using code and/or repeated multiple times on the screen. Statement A single line of a program containing a single instruction such as Text, RclPic, max(), etc. Usually synonymous with command. String A variable type that stores text as a series of characters. Subprogram A program segment which can be used more than once during the execution of a program, such as a complex set of calculations or a print routine. You can make subprograms using the Define command. ## T TI (Texas Instruments) The makers of the TI graphing calculators. In addition to graphing calculators, they also make a large assortment of other electronic devices. TI-68k The unofficial name for the TI calculators that have a 68k processor: the TI-89, TI-89 Titanium, TI-92, TI-92 Plus, and Voyage 200. These are the calculators described in this section of TI|BD. TI-Basic The unofficial name of the programming language found on TI calculators. Token A single instruction or symbol in tokenized TI-Basic that takes up 1 to 3 bytes and is used to encode TI-Basic programs. ## U User When talking about the effect of a program or command, it is the person running the program or command on his/her calculator. ## V Variable A name given to a value which may vary during program execution. A variable is a memory location where values can be replaced by new values during program execution. Although input on the I/O screen (with commands such as Input and InputStr) can be useful for some programs, dialog boxes are usually more effective. A dialog box is a typical message box that is displayed on top of whichever screen you're currently on, but without overwriting anything (so the background is restored when the dialog box is exited). # The Basics A dialog can be created by inserting a Dialog..EndDlog block into a program. The dialog will be displayed when that part of the program runs; after the dialog is exited, the program will resume after the EndDlog. Just Dialog:EndDlog would give an empty dialog box, and in fact causes an error. To provide content for the dialog box, use the following commands: Title Gives the dialog a title. There can be at most one title. If there is no title, the top of the dialog box will be blank. Text Adds a line of text to the dialog. The text must be a string, so use the string() command to display any other data type. Request Adds a text entry box to the dialog. Request takes two arguments, a line of text and a variable to store to. DropDown Adds a dropdown menu to the dialog. DropDown takes three arguments: a line of text, a list of strings for the dropdown, and a variable to store to. Text and Request can be used by themselves, giving a dialog box with no other elements in it. # Advanced Details ## Cancelling Dialogs At the bottom of a dialog box, there are two "buttons": ENTER=OK and ESC=CANCEL. If the ESC key is used to get out of a dialog, the dialog is indeed cancelled: the variables that would've been affected by Requests and DropDowns are left as they were (usually, undefined). Fortunately, there's a way to check if this happened. The system variable ok keeps track of the way that the last dialog was exited. It does this in a somewhat unusual way: if ENTER was pressed, its value is the floating-point value 1.0, and if ESC was pressed, its value is 0.0 (maybe this is a holdover from TI-83 series calculators, which stored all truth values in this way). The variable ok isn't affected by a Text instruction outside Dialog..EndDlog (which can also be exited using ESC, but doesn't have two buttons), nor by a PopUp menu. It does work when a Request instruction is used by itself outside Dialog..EndDlog. ## Alpha-lock Request Request always stores a string to its variable, but it's meant to be used for all kinds of input. As a result, there's an option to turn off the alpha-lock for it, if you're going to be inputting a number. To do this, add a third argument to Request which evaluates to 0. This functionality was only added with OS version 2.07, which might be an issue. It also doesn't actually do anything on the widescreen calculators (since those have a QWERTY keyboard and don't need alpha-lock). However, it's still there on widescreen calculators for compatibility, and just doesn't affect anything. Unfortunately, if there are several Requests in a single Dialog..EndDlog block, they can't have different alpha-lock settings. Either they all have alpha-lock or none of them do (the setting for the first Request command is used, and the rest are ignored). ## Compatibility If the text in one of the elements of a dialog is too long to fit in one line, the dialog gives a Dimension error. However, the allowed length of text varies from the TI-89 and TI-89 Titanium to the other, widescreen calculators. Thus, a dialog that works on one calculator may give an error on another. You might think that more text fits on a widescreen calculator, but that's actually not the case, because they use a different font for everything except titles. The actual limits are given in the following table: Command Widescreen (TI-92/+/V200) Standard (TI-89/Titanium) Title 50 chars approx. 39 chars Text (Dialog) 38 chars approx. 39 chars Text (simple) 34 chars approx. 37 chars Request 20 chars 20 chars DropDown 35 chars approx. 35 chars Note: "approx." means that due to the variable width of a font used, the actual upper limit varies. For DropDown, the upper limit is on the total length of the description and the longest option. It makes sense to write Dialog boxes with text that fits both sets of requirements at the same time. Then, there is no risk of the Dialog ever crashing! ## Default Values If the variables being stored to by Request or DropDown aren't undefined, they're used as default values: • For Request, if the variable's value is a string, it's pre-entered and highlighted in the request box. • For DropDown, if the variable's value is a number, the corresponding option is the one initially chosen. This can be useful for changing menu options. Alternatively, you can use it for instructions or custom default values, for example: "Enter the answer here"→answer Request "Ans:",answer  If the variable has the wrong type, it doesn't show up, as though it were undefined. # Dialog Snippets These are some common code snippets involving dialogs, that could come in handy in almost any program. Of course, the text may be customized to your needs. ## Confirmation Dialog :Dialog : Title "Are you sure?" : Text "Unsaved data will be lost!" :EndDlog :If ok=1 Then : © Continue :Else : © Abort :EndIf  ## Load/Save File :"main"→fold :Dialog : Title "Load file" : Request "Folder",fold : Request "Variable name",var :EndDlog :If ok=0 : © Abort :#(fold&"\"&var)→file © to save a file, instead do :file→#(fold&"\"&var)  It's a good idea to ask for the folder and variable name separately, because it clears up questions about syntax. Also, if you move :"main"→fold to an earlier part of the program, a folder that was loaded from once will be a default value in the dialog. In fact, for this purpose, you might want to keep two variables for saving and loading files, to allow for different default values. ## Error Dialog :Try : © main program code :Else : © if an error occurred : © handle expected errors, then : Dialog : Title "Error" : Text "An unexpected error occurred." : Text "Error code: "&string(errornum) : Text "Continue with program?" : EndDlog : If ok=1 Then : ClrErr : Goto start : Else : © clean up vars : PassErr : EndIf :EndTry  A dialog box like this will ensure that a bug in your code isn't as bad an outcome as it would be otherwise - a professional approach to handling errors. You might also want to add something like "Please mail <email address> with a bug report" to the message. Replace PassErr with something like ClrErr:Goto quit if you don't want to let the user see the error message, under any circumstances. {$part1begin}

To add a DYK, move the second DYK from {$part2} to {$part3}, and add a new DYK to {$part2}. See the Did You Know... Archives page to view the data on this page in a cosmetic format. {$part1end}
{$part2begin} …that it is actually sometimes better to leave on the closing parentheses on the For( loop? …that a memory leak is caused when you use a Goto/Lbl within a loop or If conditional (anything that has an End command) to jump out of that control structure before the End command is reached? …that you can omit the closing parentheses, quote, square bracket, curly brace, etc. at the end of a command or function? {$part2end}
{$part3begin} …that while using seq(, the calculator can still interpret keypresses and store them to getKey? …that you can use tanh(E9X to compute the sign of X? …that Line( has an optional fifth argument that, if zero, will erase the pixels on a line? …that you can remove the "Done" message that appears after a program is finished running by placing an expression, some text, or just a quote on the last line of your program? …that you can use rand(# to create a time delay? …that you can use multiple text arguments at the end of one Text( command to write, for example, Text(R,C,"Score",S)? …that you can draw with different plot marks using Pt-On(X,Y,#)? …that you can save memory when displaying text by replacing words such as "If" and "Time" with the appropriate commands? …that "0<X<10" will actually compare "0<X" first, and compares the result (0 or 1) to 10, so "0<X and X<10" should be used instead? …that using ΔList( together with cumSum( will return a list with its first element removed? …that there are 256 picture variables built-in to the TI-83+ calculator, even though the calculator only shows 10 picture variables? …that you can enable the faster circle drawing flag on the TI-83+ by placing a list with an imaginary i after the last argument of the Circle( command? …that you can get the home screen font on the graph screen (except on the regular TI-83) by placing a '-1' at the beginning of the Text( command? …that you can get the number of digits in a whole number by using the formula 1+int(log(#? …that the smallest way to implement the distance formula is by using the R►Pr( command? …that you can use the % symbol or sub( with one argument as a smaller replacement for multiplying by .01? …that you can get rid of the run indicator by using Text(-1,0,90," ") on the graph screen and Output(1,16," ") on the home screen? …that you can run your TI-Basic program from an assembly shell by placing a colon (":") as the first line of your program? …that you can store to the list element one past the last element to add it to the end? …that it is actually sometimes better to leave on the closing parentheses on the For( loop? …that the finance variables are the fastest variables to use, even faster than Ans? …that the String►Equ( command is completely useless, and you can store a string into one of the equation variables just using the → (store) operator? …that the fastest way to check for a whole number is not(fPart(? …that you can compress a list of related numbers by combining them into integer and fraction parts? …that the majority of the graphics commands are dependent upon the window dimensions, so you should always use a friendly graphing window to ensure everything shows up as you intended? …that you can make subprograms that are contained inside the program itself, so that they can be called by the program whenever needed? …that you can use SetUpEditor to UnArchive a list, but at the same time create it if it doesn't exist? …that you can get away with not having a colon or a new line after DelVar? …that placing a Lbl after DelVar will make that Lbl literally disappear? …that you can scroll the Pause command's optional argument to see it in its entirety? …that the smallest (though not the fastest) way to shade the entire graph screen is Shade(Ymin,Ymax)? …that pressing alpha in the program editor followed by up or down, you will scroll a whole page of program code? …that pressing 2nd right in the program editor will take you to the end of your current line, and 2nd left will take you to the beginning of that line? …that TI added several new TI-Basic commands to the newer TI-84+/SE calculators? …that any math calculations that involve extremely small or large numbers (ranging from -E99 to E99) will produce rounding errors that don't return the right number? …that a memory leak is caused when you use a Goto/Lbl within a loop or If conditional (anything that has an End command) to jump out of that control structure before the End command is reached? …that a Repeat loop will always loop at least once, regardless of if the condition is true or false before entering the loop? …that the arrow and DEL keys can actually be held down, which will cause the key to keep being repeated until it is unpressed? …that the key codes follow a simple pattern: a key is represented by putting its row and column together? …that you can access the lowercase letters by using an assembly program to turn on the lowercase flag that the calculator uses for enabling lowercase letters? …that the Horiz will split the screen in half horizontally, with both the graph screen and home screen being shown at the same time? …that the expr( command allows you to store an expression to a string and then execute the string? …that the TI-83 series of calculators does implicit multiplication, so there is no need to ever use the * sign? …that iPart( and int( will return the same answers for positive numbers, but int( will return an answer 1 less than iPart( for (non-integer) negative numbers? …that lists are the only variable that you can give your own names to? …that you can omit the closing parentheses, quote, square bracket, curly brace, etc. at the end of a command or function? …that Finance under the Applications menu is really not an application at all? {$part3end}

Did you know…

The ListPages module does not work recursively.

This is a list of the bugs that have been discovered in TI-Basic when using the different commands. These bugs appear on their respective command pages as well, but are placed here together for sake of completeness (that way you don't have to go hunting around the site).

## Using String►Equ(

The String►Equ( command is supposed to store the contents of a string to an equation variable (such as Y1 or X1T). In practice, however, this command is completely useless. This is because the (store) operation can be used for the same purpose:

:String►Equ(Str1,Y1
can be
:Str1→Y1


This replacement is universal, takes the same time to run (because it actually uses the same routines), is more convenient to type since you don't have to go through the command catalog, and is several bytes smaller.

## Using DelVar

If DelVar is used in a For( loop to delete the counter variable, or used to delete the variable and/or value in the IS>( or DS<( commands before using them, it will cause an ERR:UNDEFINED error.

Another bug when using DelVar is with its chaining of variables functionality: the DelVar command also allows you to take the command from the next line and put it immediately after the DelVar command.

:DelVar A
:Disp "Hello
can be
:DelVar ADisp "Hello


There are two cases in which the following statement will be ignored, so you should add a newline instead:

• The End from an If statement.
• A Lbl command.

## For( Loops

When a For( loop doesn't have a closing parentheses after it, it will actually slow down If statements with a false condition inside the loop that immediately follow the For( line. This doesn't affect the speed of any other commands (except IS>( and DS<( which are rarely used), nor does this effect occur with a true condition or If-Then-End blocks (just with a single If and a command following it).

 :For(I,1,100 :If 0: :End  :For(I,1,100) :If 0: :End 

These two pieces of code, for instance, are nearly 20 times different in speed, which is a major speed hit in TI-Basic. As a general rule, if there is any chance at all that the condition is false (which is always the case, or else why are you testing for it in the first place?) result, then you should leave on the parentheses on the For( loop.

However, this bug does not occur when there is a line or code between the For( line and the If statement.

 :For(I,1,100 :1 :If 0: :End  :For(I,1,100) :1 :If 0: :End 

These two pieces of code execute at the same speed. However, the left example is one byte shorter. As an optimization, omit the closing parenthesis of the For( loop if there is an extra line or code that occurs between the two statements.

## Rounding Errors

Because of the way that TI designed the TI-Basic language, each number has a limited amount of precision. As a result, any math calculations that involve extremely small or large numbers (ranging from -E99 to E99) will produce rounding errors that don't return the right number. There are a couple different ways you can deal with this problem.

The round( command will round a floating-point number so that it has the specified number of decimal digits. While you can hypothetically set it so that it has 25 digits, the calculator only allows a number to have up to 14 digits, which means the range is 0-14 digits.

:Output(Y,round(X,0),"X
:If E‾9>Ans(2


Another way to deal with the problem is by multiplying the number by a smaller number (for example, E-9). The calculator will automatically treat the number in a similar fashion to the smaller number, which allows it to make the math expression work. Truthfully, neither of these methods is fool-proof, so you should just be aware of the problem.

Program Summary

A quality version of the classic frogger game.

Program Size

1,232 bytes

Uses Libraries?

No, it's pure TI-Basic

Calculator Compatibility

TI-83/84/+/SE

Author

SiCoDe (Douglas O'Brien)

Download

frogger.zip

Frogger's claim to fame is that it was the very first game to utilize the home screen scrolling made possible by using the Output( command together with a string. The Output( command has wordwrapping functionality built-in, in which any text that goes over the 16 characters of a row will be wrapped to the next row (and likewise with that row), and subsequently you can use a single Output( command to display an entire screen of text.

This functionality not only allows the text to be displayed very quickly — in fact, there is no faster way to display text in TI-Basic — but also very efficiently. What people were doing previously was actually just using several Output( commands, and then displaying each row of the screen separately. Obviously, this approach does not lend itself to making fast games, and so most games were rather slow.

The basic idea behind Frogger is that you control a frog that you can move in the four directions, and you want to get to the other side of the road as quickly as possible. This is made more difficult because you have to avoid getting hit by the moving cars that are coming at you. You are given points based on how many times you make it across the road, as well as how fast you do it.

A long program can get complicated to manage when it's all in one piece. For this reason, it's often easier to write code with a main program that does its job by running several other programs called subprograms. In fact, it's fairly easy to start using this method from the planning stage.

There are other benefits to using subprograms, of course. It's good to define a subprogram for a task that needs to be done more than once. Also, a subprogram can run itself recursively, if necessary.

Of course, you don't want to release a finished program in lots of pieces, so at the end of the day, you want to incorporate the subprograms in the main program. If the subprogram isn't recursive and is only used once, this is easy: just use 2nd RCL to recall the subprograms into the place where they're used, and remove their Prgm..EndPrgm parts. See the next section for what to do in more difficult cases.

# Defining a Subprogram

You can also define a subprogram right in your main program. This is done using the Define statement:

:Define subprgm()=Prgm
: © subprogram code
:EndPrgm


It's easiest if all the subprograms are defined at the same time, near the beginning of the program, but it doesn't really matter where you do it as long as you define the subprogram before you use it.

# Cleaning Up

It's important to realize that a subprogram defined in this way is just like a regular variable. If you don't do anything, then after the main program finishes running, the subprogram will be left hanging around, which is usually not a good thing. As with other variables, there are several ways to clean this up:

• Use Local to declare the subprograms as local variables (e.g. Local subprgm1, subprgm2).
• Use DelVar at the end of the program to delete the subprograms (e.g. DelVar subprgm1, subprgm2).
• Give the programs one-letter names, and use NewProb at the end of the program.

See Setup and Cleanup for more information on how to do this.

Hop Over is a simple game designed to test your mental fortitude. There are two types of pieces, squares and crosshairs, and they can only move left and right respectively. The pieces are allowed to jump over one another, but only if there is a free space available in the given direction. The goal is to get four squares on the right, four crosshairs on the left, and an unoccupied space in the middle. Like with the other games, try out the game and try to understand and think through the code.

(NOTE: This game was created by Weregoose, and originally posted on the UTI forums.)

 Table of Contents

## The Code

:StoreGDB 1
:FnOff
:ClrHome
:ClrDraw
:GridOff
:AxesOff
:PlotsOff
:0→Xmin:1→ΔX
:0→Ymin:1→ΔY
:Text(17,32,"HOP-OVER
:38:Line(23,Ans,71,Ans
:Line(71,Ans,71,28
:23:Line(71,28,Ans,28
:Line(Ans,28,Ans,38
:For(A,1,9
:If A≠5
:Pt-On(5A+22,31,2+(A<5
:End
:DelVar B47→A
:Repeat C=45
:Repeat C=45 or 42=abs(C-63)pxl-Test(32,Ans
:If C≠21:Then
:Pt-Off(B,35,3
:Line(B-2,36,B+2,36,0
:Pt-On(A,35,3
:Line(A-2,36,A+2,36
:A→B
:End
:Repeat Ans
:getKey→C
:End
:A+5((Ans=26)-(Ans=24
:Ans+45((Ans=22)-(Ans=72→A
:End
:If C≠45:Then
:pxl-Test(31,A
:5(Ans-not(Ans→D
:pxl-Test(32,A+Ans
:Pt-Off(A,31
:Pt-Off(A,31,2
:Pt-On(A+Dnot(Ans)(A≠4D+47)+2DAns(A≠3D+47)not(pxl-Test(32,A+2D)),31,2+(D>0
:End
:End
:RecallGDB 1


## The Download

In case you want to try the program on your calculator, you can download the program in .8xp format.

Routine Summary

Returns a subset of a number.

Inputs

A - the number to get the subset from
B - the starting position of the subset
C - the length of the subset

Outputs

Ans - the subset of the number

Variables Used

A, B, C, Ans

Calculator Compatibility

TI-83/84/+/SE

Author

Weregoose

URL: United TI

Download

numbersubset.zip

:10^(2-B+int(log(A
:int((A-int(A/Ans)Ans)/Ans10^(C


With our number stored in A, and the staring position and length of the subset stored in B and C respectively, we get the subset of the number by first subtracting the number divided by 10 to the power of 2-B+int(log(A (which is used to get how many digits are in the number), and then dividing that result by multiplying 10 to the power of 2-B+int(log(A and 10 to the power of C (which is the length of the subset).

A simple example should help you understand this routine. Say you input the number 123, with a starting position of 2 and a length of 2, it will return a result of 23. You can also use negative and decimal numbers with the routine, and it will still work correctly: a number of 13579.02468 with a starting position of 4 and length 4 will return 7902.

This routine is comparable to the sub( command that works with strings.

Routine Summary

Concatenates two whole numbers together.

Inputs

M - the first number
N - the second number

Outputs

O - the concatenated number

Variables Used

M, N, O

Calculator Compatibility

TI-83/84/+/SE

Author

DarkerLine

URL: United TI

Download

numberconcatenation.zip

:N+M10^(1+int(log(N→O


With our two numbers stored in M and N respectively, we add the first number to the second number by raising it to the 10th power, with the exponent being how many digits are in the number. We then store this result to a new variable for later use.

We can figure out how many digits are in a number by using the 1+int(log( trick. This trick works with any positive whole numbers, and if you add abs( after log(, it will also work with negative numbers. Unfortunately, it does not work with decimals.

Fly The Copter is a simple game where you have to navigate a scrolling tunnel for as long as possible, and you need to press 2nd to move the copter higher in the air, and don't press anything to lower the copter. Smoothscrolling isn't very viable in pure TI-Basic, so the way this game works is that once your copter gets to a certain point on the screen, the next part of the tunnel will be redrawn and the copter will be redisplayed at the beginning of the tunnel. Like with the other games, try out the game and try to understand and think through the code.

(NOTE: This game was created by Weregoose, and originally posted on the UTI forums.)

 Table of Contents

## The Code

:FnOff
:ClrHome
:ClrDraw
:GridOff
:AxesOff
:PlotsOff
:0→Xmin:1→∆X
:0→Ymin:1→∆Y
:20→G
:For(X,0,47
:Vertical X
:Line(X,Ans,X,Ans+G,0
:Ans+randInt(-(Ans>2),Ans<53-G
:End
:Ans→X:-1→A
:31→B:.2→F
:For(θ,0,E9      // scientific E, not the variable E
:Text(0,0,θ
:If not(fPart(A/3
:Pt-Off(C,D
:Pt-On(A,B
:A→C:B→D
:getKey→E
:F-.1+.3(Ans=21→F
:B+Ans→B
:(A+1)(A≠Xmax→A
:G-.5not(Ans→G
:A+47-95(A>47
:Pt-On(Ans,X+randG,1+not(fPart(θ/32
:Vertical Ans
:Line(Ans,X,Ans,X+G,0
:X+randInt(-(X>2),X<53-G→X
:G-not(A→G
:If E=105:Pause
:If not(E=45 or pxl-Test(Ymax-round(B,0),A
:End
:For(C,1,9
:Pt-Change(A,B
:rand(20
:End
:ClrHome
:ClrDraw
:Disp "Distance:
:Output(1,10,θ


## The Download

In case you want to try the program on your calculator, you can download the program in .8xp format.

Imagine you are using a program for the first time. You have no prior knowledge about the program; someone just put the program on your calculator without giving you any instructions and now you are trying to figure out how to use it. After literally pressing all the buttons on the calculator and trying all sorts of key combinations, you give up and tell your friend the program was useless. You then delete the program because you figure it's worthless if you can't use it.

This example isn't based off any one particular program (I don't want to name names, but more importantly talk in the general sense), but it does resonate with lots of program users who have had a similar experience. What this problem really is about is poor user-friendliness — more commonly known as usability. The definition of usability is simply how easy it is for people to use a program, and how much value it provides.

While usability can take on many different forms, there are some essential things that you can do to make a program more user-friendly.

# In-Game Help

Probably the easiest way to make a program user-friendly is by including some in-game help. While you ideally want your program to be so easy to use that a user can simply pick it up and figure out how to play it, not every game is so straightforward, and the average user probably needs some help.

The best place to include help in a program is as one of the options in the program's menu. When the user comes across the menu, they will see the help option and they can select it to view the help. The help does not need to cover every minute detail about the program, but rather just explain the objective of the game and detail what keys are used for controls.

:PopUp {"Option 1","Option 2","Help"},option
...
:If option=3 Then
: Dialog
:  Title "Help"
:  Text "The game objective is ..."
:  Text "Use the ENTER key to ... "
: EndDlog
:EndIf


Because most people do not like using help unless they have to, you should try to limit your help to one or two screens at most. At the same time, if you have an extremely complex game with all sorts of features and lots of keys are needed to operate it, then it would be appropriate to include help for all of those things. The general guideline is that the amount of help needed correlates to the size of the game.

# Protect the User

The next thing you can do to make a user-friendly program is to protect the user from themselves. Often times in a program you will want to think about what could go wrong and try to either prevent it from happening or tell the user what's wrong. Preventing it from happening involves you, the programmer, programming in safety protections for the user so that they aren't even aware that something went wrong.

Say the program calls for the user to type in a number between 1-1000 and the user types in 5000. If your program just goes on with this value, it will probably crash at some point later on. Rather, it's necessary to check the value and ask for the number again if it's wrong. For example:

:Input "Enter a number 1 to 1000",n
:While n<1 or n>1000
: Disp "The number must be 1 to 1000!"
: Input "Enter the number again",n
:EndWhile


Sometimes it might be impractical to check whether an input is valid. In that case, an alternative is to use Try..Else..EndTry blocks. If an error occurs, the program will jump to the "Else" part of the block, with the error code stored to the system variable errornum. You can either display a generic error message or try to use the error code to figure out what went wrong.

# Teacher Key

Another part of making a user-friendly program is to include helpful features. Since the target audience is often in high school, a feature sure to be appreciated is a "teacher key." This is a special key that the user can use to quickly exit the program. When the teacher comes around, they then want to be able to get back to the home screen] so they don't get their calculator taken away.

This problem is quite easy to prevent with a teacher key. In every program there is a main loop that runs throughout the life of the program. You need to add a check for whatever teacher key you want at the place in the main loop where you check for user input. Make sure, of course, that the user knows which key is the teacher key!

:Loop
: ....
: getKey()→key
: If key=<teacher key>
:  Exit
: ....
:EndLoop


# Progress Indicators

In games that use maps, the program has to go through the list of maps and then load the appropriate one for the user to use. Depending on the size and number of maps, this can take a while. If the user doesn't know what is going on, they probably will think the program stalled or something else went wrong.

While there are a couple different ways you can cut down on the loading times for maps (see subprograms and compression), the easiest way to solve the problem is by simply telling the user what is going on and showing the user some progress. You don't have to do anything fancy (in fact, you probably shouldn't because that would just waste valuable memory), just something to help the user understand the situation.

For example, say you are randomly placing mines throughout the map (it's a Minesweeper game), you then could just display a "Placing Mines" message on the screen and then have a loop for the progress indicator that matches the current map loading:

:For x,1,20
: © fill the map with mines
: Output 0,0,"Placing mines: "&string(x)&"/20"
:EndFor


# The KISS Principle

The last important point of program user-friendly is following the KISS principle. For those who haven't heard of KISS, it is an acronym which stands for Keep It Simple Stupid. The basic point of KISS is to not clutter your program with unnecessary features and useless fluff. It also entails making the program easy to figure out for those who don't have access to a readme.

It is not uncommon to see a TI-Basic math program (i.e. quadratic solver) that has a menu, about screen with scrolling credits, and includes some game in case you somehow get bored solving quadratic equations. While those things by themselves aren't bad, they are completely inappropriate in a math program. There is a certain elegance that comes with "programs that do one thing and do it well." This is known as the Unix_philosophy, and should really be what every program strives for.

Program Summary

Try to hit the enemy base while avoiding the missiles flying at you.

Program Size

2,000 bytes

Uses Libraries?

No, it's pure TI-Basic

Calculator Compatibility

TI-83/84/+/SE

Author

SiCoDe (Douglas O'Brien)

Download

war.zip

War's claim to fame is that it was one of the very first games to utilize the home screen scrolling made possible by the Output( command. The Output( command has wordwrapping functionality built-in, in which any text that goes over the 16 characters of a row will be wrapped to the next row (and likewise with that row), and subsequently you can use a single Output( command to display an entire screen of text.

This functionality not only allows the text to be displayed very quickly — in fact, there is no faster way to display text in TI-Basic — but also very efficiently. What people were doing previously was actually just using several Output( commands, and then displaying each row of the screen separately. Obviously, this approach does not lend itself to making fast games, and so most games were rather slow.

The basic idea behind War is that you control a ship that you can move up or down, and you are flying over an enemy base that you must drop bombs on. This is made more difficult because you also have to avoid getting hit by the missiles that are flying at you, while at the same time you need to time the bomb drops so that you actually hit the enemy base. You are given points based on which type of enemy base you hit, and you must get a certain amount of points within the allotted time.

After spending considerable time making a program that you are proud of, the natural next step is to try to get people to start using your program. After all, a program is nothing without people downloading and using it. The way to achieve this is by marketing the program to other TI-Basic programmers and gamers in the TI community.

Marketing consists of three main channels: advertising, public relations, and email. Probably the best place to advertise a program is on TI-Basic forums. Forums typically get the most visibility (i.e. traffic) simply because they are a nexus for lots of like-minded people to come together to communicate and freely talk. Besides the posters, there are lots of visitors/lurkers who frequent forums.

When marketing on the forums, try to be honest about your program's merits and avoid any needless hyping; let your program's quality speak for itself. People are keenly aware of when wannabe TI-Basic programmers are all smoke and mirrors (with no real substance), so how you present your program is extremely important.

The other way to market your program on forums is to post a download link to the program in your signature. Depending on how often you post on the forums you frequent, sooner or later people will see the link to your program and curiosity will cause them to click the link. This is marketing in a simple, yet effective way.

Public relations marketing involves using two main resources: your own website or group and affiliating with other TI-Basic programmers and groups. If you have your own website and/or are part of a TI-Basic group, consider announcing the release of your program in a news post and asking the other members in your group to download the program. In addition, ask them to tell other TI-Basic programmers and gamers about it.

Related to having your own website or group, think about affiliating with other TI-Basic programmers and groups. These people already have a built-in audience that you can market your program to and they are probably willing to help you out with the marketing. It can't be said enough that building bridges in the TI community goes a long way towards marketing success. This is especially true if the affiliates have a good reputation in the community, since they have some sway on other TI-Basic programmers.

Email is often the most forgotten part of marketing because it involves contacting people on an individual basis. However, email marketing can be very effective because it has a personal element to it which other marketing channels simply don't have. When using email, try to tell the person about your program and how you think it might be useful to them. Even if the person tells you they're not interested, they will usually thank you for taking the time to email them.

Regardless of which way(s) you market your programs, always remember that there is a delicate, fine balance. Once you misuse or go overboard with marketing, it not only makes people not want to download your programs but it takes a long time for people to change their opinion of you; your reputation in the community is extremely hard to get back once it is ruined. So, try to create the highest quality programs possible and use wise marketing sense.

Screenshots are one of the best ways to advertise your program at any stage of production. They're also great for explaining a problem you have, explaining how to fix a problem, demonstrating a calculator feature, or being displayed at the top of a TI-Basic Developer page. This tutorial will explain you some easy ways to create still and animated screenshots.

To begin with, you'll need an emulator (see the downloads page). If you're taking a screenshot of a program on your calculator, you'll need to send it to the computer (see linking) first, then transfer it to the emulator. Although there are many methods of taking screenshots, I'll only cover a few of them.

# Still Screenshots

These are easy to make with any emulator, even one that doesn't have any screenshot functionality. You can simply use the Print Screen key on your computer to take a screenshot of the entire screen. Then, use any image editor, even one as simple as MS Paint, to remove everything except the emulator's image of the calculator screen. You can also add a border or anything else easily at this point. Save the image and you're done!

# Animated Screenshots with CalcCapture

CalcCapture allows you to take an animated screenshot of almost any emulator, with any skin. To begin using it, download CalcCapture, and run it (it doesn't require installation) at the same time as the emulator.

The first time you're using CalcCapture with a particular emulator, press the Configuration button at the top right of the CalcCapture window. Then press New at the top to configure a new emulator. Select the calculator you're emulating, and press the button to the right of the Windows Title field to select the window with the calculator in it. Press Capture to take a screenshot of the window at this moment, and arrange the numbers for the emulator window so that they match the calculator screen. (see the page on the various calculator models to see what the screen sizes are). Press OK when you're done.

For taking screenshots, the default settings should be sufficient. Choose ANIMATION for the "Capture Type" option, and enter the file name you want. Then press Capture and Stop Capture when you want to take the screenshot (or, you can use a hotkey). The counter at the top right of the screen shows the number of frames that have been captured.

# Some Considerations

When taking animated screenshots, try to plan out what you're going to show before taking the screenshot (if possible, down to the keys you're going to press). Don't include any of the unnecessary detail, like selecting the program out of the menu and pressing ENTER (start in the program itself).

If an actual screenshot is out of the question for one reason or another, consult the Fake Screenshots tutorial.

After spending lots of time planning a program, then coding it, and finally optimizing it, the next move for many people is to call the program "done" and release it to one of the major TI sites (such as ticalc.org, calcgames.org, or unitedti.org). Unfortunately, these people are leaving off one of the most important steps of the programming process: documentation.

Now, I'm sure some of you are probably wondering what is so important about documentation and why it is necessary in the first place. You might even be asking, "If we design the program so it is user-friendly, isn't that good enough?" The answer to that question is a resounding NO! In reality, documentation is a crucial part of a program.

When you release a program to the public, you need to remember that there are all sorts of program users out there — they literally run the gamut. Because of this, you need to always try to keep your basic, simplest program user in mind (those with little or no calculator savvy). These people are (typically) not familiar with the calculator beyond just using it for playing games, so they need all the help you can give them for using your program.

Writing documentation for your program is one of the best ways you can help your users: the basic users don't want to have to spend lots of unnecessary time trying to figure out how to use your program and the hardcore gamers consider a program without documentation to just be distasteful (some don't even download a program unless it has documentation).

While there are literally an infinite number of things that you can include in program documentation, you should always at least include the basic essentials about your program. (It is your decision whether you decide to include any of the extras, but keep in mind that the more detailed your documentation is the better it will be for the program user):

• Author information (including contacts)
• Program description
• Calculator requirements
• Installation (if necessary)
• Instructions
• Files included in zip
• Program controls
• Troubleshooting

Besides the things listed in the list, you might also want to include some technical information. If you have a quality program with some exceptional code, other less knowledgeable users would probably be interested in studying the technical information from your program so they can learn from it. This not only allows them to become better programmers, but they might even be able to add on to your program with more features, functionality, or whatever.

When naming your documentation, try not to use a generic name like readme.txt. This is the current standard, but it doesn't work very well when a person has several programs stored in the same folder at the same time. Instead you should name your documentation after the name of your program. For example, if your program's name is Donut Quest, your documentation should be named DonutQuest.txt. This makes it much easier to maintain order.

Many programming guides give you excellent advice on programming but stop at the point when the program is finished, tested, and optimized. After all, most people can manage to release a program somewhere, one way or another. But in reality, an inexperienced programmer may well release his work quietly and in an unassuming form, which people will simply glance over without stopping. This tutorial will tell you how to avoid this, and make your program get all the attention it deserves.

# Where to Release

First, it's important to know where to go to upload your program to the Internet. Although you might want to create your own website and release all your games there, that alone will not get your program noticed. Sure, having your own site might get you some publicity, but the best way to get your game noticed is by releasing it at one (or all!) of the large program archives.

Of these, ticalc.org is by far the largest (and most popular), but it's also likely you'll spend longer waiting for your program to be put up there; the other two will put it up in no more than a day or two.

# What to Release

There's more you'll want to submit than just the program itself. Here are the elements you'll want to put together — some of these are called optional by the file archive websites, but they are mandatory if you want the program to be successful.

The program itself (obviously)

If you were programming on the calculator, you'll need to transfer the program to your computer to submit it. You'll need a calculator-to-computer cable, and software such as TI-Connect. If you don't know where to get these or have problems using them, see linking.

Now, you have one or more files from your calculator on the computer. If there's only one, you're good to go. If there are several files involved, you should make sure to mention what each file is for, in the readme.

The README

A critical step in submitting a program. Make sure to read our tutorial on writing a readme if you've never done it before (and possibly even if you have). Usually, longer is better than shorter (it's worse if someone doesn't understand how your program works, than if they have what they already know explained to them again) — unless it's a five-act play, in which you might consider removing the nonessentials. Generally, the longer and better your program, the longer your readme can be; you don't need any more than the minimum for, say, a quadratic solver.

Also, please don't make the readmes in Microsoft Word 7 file format! A .txt file is sufficient, and in fact recommended.

The screenshot

All three websites listed above let you add a still or animated screenshot of your program. This is very easy to do — see the making a screenshot page — and goes a long way toward making your program look good (if it actually is good). An attractive screenshot will encourage visitors to download your program more than the most flowery prose. Show your program at its most impressive here.

The title

The title will tell visitors what your program is all about. One common mistake is making the title the same as the 8-character name of the program. Don't do this — the title is the first thing people will see, and you want to make it clear. Of course, if the program is called tetris() it's okay to call it Tetris (though Grayscale Tetris, if that's the case, could be even better). But if the program is called quadsolv(), please make the title Quadratic Solver instead!

The description

Don't forget this! It should have three parts:

• What the program is about. "Solves all quadratic equations over the complex numbers."
• The program's best qualities. "A grayscale interface at the low size of 13 bytes!"
• Any requirements. "Requires flib to work correctly. Also, put each attached file in its own folder."

The first two parts are positive; the third is negative, but necessary (imagine if your program crashes without warning if a specific file is not created first. 99% of your users will be lost, even if this is explained in the readme, and write negative reviews). You want to make this section as short as possible, and the best way to do this is to avoid the requirements in the first place. Also, you don't have to mention anything already obvious: if your program is in the "Basic games for flib" section, you don't have to say anything about flib here.

Putting this together

The program and the readme should be combined in a .zip archive, this is a community-wide standard. The file upload form (this is different for all websites, but contains the same basic information to be entered) should have fields where you can submit everything else. You might also consider adding the screenshot to the .zip archive, in addition to its normal location.

Here are the links to the file upload forms of all the websites mentioned on this page.

# Marketing

Marketing your program can start as early as when you first get the idea for your program, although many people won't take you seriously until you have at least a basic engine to show for your efforts. Other good points at which to advertise the program include a beta-testing period before you release it to the masses, and of course when it's finally released. For more marketing tips, see our marketing tutorial.

When you are in the process of writing a program, everything about the program (i.e., variables, program structure, branching labels, etc.) is fresh in your mind and it's easy to remember. But what would happen if you stopped working on the program for a year, and then decided to start working on the program again?

All or most of your previous knowledge of the program would be gone, and you would have to spend some time (or lots of time, depending on the program) to figure out how the program works again. While this is only a hypothetical example, this problem is a real concern for lots of people who have multiple projects going at any one time.

Thankfully, this problem can be easily prevented by simply adding comments to your code. A comment is a brief note that describes some functionality or feature of your code. You don't need to comment everything, but the two main things that you should comment are:

• Program Structure — Loops and branching with appropriate label names
• Variables — What their purpose is and any possible values used throughout the program

The amount of free RAM is the only limit on comment size, but you should generally try to keep your comments clear and concise. In addition, if your comment is more than a couple lines in length, you should split it up into multiple lines. This makes it easier to read and update, if needed.

A common theme you'll see in this section is adding extra formatting while the program is being written (to make it readable), and taking it out before releasing the program (to make it as small as possible). This is common practice in TI-68k programming. You might also consider keeping a backup copy of the commented version of the program even after it's released, in case you need to fix bugs or decide to make an updated version.

# Adding Comments

TI-68k calculators support a built-in way to add comments. When you type the copyright character © in a program line or expression, the rest of the line will be considered a comment, not code.

However, comments do increase the size of the program considerably. Consequently, you should remove all the comments from your program before you release it to the public, to ensure that it is as small as possible. In addition, you don't want your users accidentally seeing something they shouldn't be seeing.

# Making Code Stand Out

If a section or block of code needs to be graphically separated from the rest of the code an easy way to do this is to add extra spaces at the beginning of each line:

:Loop
: Text "Hello!"
:EndLoop


This is a built-in way to indent code, and in fact the number of indentations is stored automatically with each line of code. This means that (unlike most other formatting) the indentations won't disappear after the program is tokenized, and also don't increase the program size.

# Using Descriptive Variable Names

Yet another way to help indicate what a code block is doing is to use good variable names that reflect what is stored to them. It's true that one-letter variable names are much smaller and slightly faster, so you should use them as much as possible in the released version of a program. However, while programming, descriptive variable names are very helpful. Using the Find feature of the program editor, it should be easy to change the name of a variable whenever needed.

When choosing variable names, you might want to add a way to indicate the variable type, since it's otherwise hard to tell in some cases. Except in rare cases such as For loop indices, avoid using the same variable for different purposes. Finally, it's a good idea to add a comment at the beginning of the program explaining the purpose of the variables.

Simon Says is a simple game where you are given a pattern that must repeat, and the pattern gets longer and longer which subsequently increases the difficulty. This version of the game is played on the home screen, and is quite small (approximately 214 bytes). You use the respective number keys to type the matching number. Like with the other games, try to understand the code and experiment with it.

 Table of Contents

## The Code

:For(I,1,16
:ClrHome
:DelVar L₁"?→Str1
:For(J,1,I
:randInt(1,5→B
:{92,93,94,82,83
:Ans(B→L₁(J
:Str1+sub("12345",B,1→Str1
:End
:Output(1,1,sub(Ans,2,length(Ans)-1
:rand(10I
:ClrHome
:For(J,1,I
:Repeat Ans
:getKey
:End
:If Ans≠L₁(J:Goto Q
:Output(1,J,sub(Str1,J+1,1
:End
:rand(20
:End
:Lbl Q
:Pause "YOU "+sub("LOSE!WIN! ",1+5(I=17),5
:ClrHome:"


## The Download

In case you want to try the program on your calculator, you can download the program in .8xp format.

Program Summary

A quality version of the classic connect 4 game.

Program Size

4,000 bytes

Uses Libraries?

No, it's pure TI-Basic

Calculator Compatibility

TI-83/84/+/SE

Author

SiCoDe (Douglas O'Brien)

Download

connect4.zip

Connect 4 is one of those rare TI-Basic games that utilizes smart AI, which is important when you want to play a game, but there is nobody around to play it with. Unlike other Connect 4 clones with simple AI, where you can beat it fairly easily, the AI in this game not only doesn't any mistakes, but you need to get it into a double-bind situation in order to win (meaning you can win multiple ways at one time, but the AI can only cover any one of them each turn; just like in tic-tac-to).

In terms of gameplay, Connect 4 only provides the 1player versus AI game mode, which means that you can get tired of playing the game after a while. However, if you get tired of playing the game, you can always study the code to better learn how to put together you own Connect 4 game :D The game controls are very simple: left and right to move the cursor, and 2nd/ENTER to drop a piece down one of the slots. The game ends when somebody gets four pieces in a row, or all of the spots on the board are filled up.

If you have ever played any of the snake, mofrog, nibbles, etc. games, then this game should be familiar to you. The basic premise is to go around eating food and the snake grows longer with each piece of food. Like with the other games, try out the game and try to understand and think through the code.

 Table of Contents

## The Code

:26→K
:1.1→B
:{4Ans→A
:ClrHome
:For(A,1,E2
:randInt(1,16)+.1randInt(1,8→C
:Repeat C=Ans(1
:A→dim(⌊A
:⌊A(1
:Output(10fPart(Ans),int(Ans),"O
:Output(10fPart(B),int(B),"   // 1 space
:Output(10fPart(C),int(C),"*
:getKey
:If Ans=45
:Goto 0
:If Ans=34 or 2>abs(Ans-25
:Ans→K
:⌊A(A→B
:⌊A(1)+(K=26)-(K=24)+.1((K=34)-(K=25
:If max(LA=Ans
:Goto 0
:Ans+16(not(int(Ans))-(17=int(Ans)))+.8(not(fPart(Ans))-(.9=fPart(Ans
:augment({Ans},⌊A→A
:End
:augment(Ans,{Ans(A→A
:End
:Lbl 0
:ClrHome
:A

## The Download

In case you want to try the program on your calculator, you can download the program in .8xp format.

## Other Versions

Snake is a rather popular game to code since it showcases many features of the TI-BASIC language and provokes algorithmic thinking. Below are some other snake clones that you can study and compare to observe the classic tradeoffs in speed, memory efficiency, features, and aesthetics.

• XSnake by XprO — Optimized for pure speed
• Nibbles by Edward H — Requires no auxiliary lists, and hence memory efficient
• Nibbles Arcade by SiCoDe — Feature-heavy with snake variations and an AI

Although many people have created TI-Basic programs over the years, and TI-Basic often gets a bad rap for being so limited compared to assembly, these programs will show you that TI-Basic can be used to create quality programs.

Name Size Libraries? Compatibility Author
Bang Bang 3,670 No TI-83/84/+/SE Sean Weeks
Checkers 13,249 No TI-83/84/+/SE nitacku
Chess Pro 6,869 No TI-83/84/+/SE Francis Huang
Connect 4 4,000 No TI-83/84/+/SE SiCoDe
Dots 1,311 No TI-83/84/+/SE Travis Fischer
Lights Out 3,400 No TI-83/84/+/SE Scott Davis
Minesweeper 3,339 Yes TI-83+/84+/SE Fred Sparks
World Domination 10,000 No TI-83/84/+/SE Kerm Martian
World Empire 5,714 No TI-83/84/+/SE Arthur O'Dwyer
Xmove15 1,574 No TI-83/84/+/SE XprO

This fixed-width character set is generally found on the home screen. For the smaller font, please see this article.

# Character Map

The order of the characters is rows then columns, so that is 01
Click on any character to jump ahead and view its respective details.
 0 1 2 3 4 5 6 7 8 9 A B C D E F 0 1 2 3 4 5 6 7 8 9 A B C D E F

# Introduction

The following chart depicts each character with its hexadecimal equivalent, name, and possible BBCode representation (the latter of which need only be copied and pasted directly into a message board post). Most likely, any numeric character references (e.g., &#9658;) included will be automatically converted upon previewing or sending the message.

While there are more accurate Unicode-based substitutes for many of these characters, a rather large user base lacks the fonts or settings necessary to render them in a visually useful manner, or at all. Consequently, precision as there might have been in more well-suited environments has been sacrificed to permit a higher rate of good cross-browser performance. For instances where a sufficient alternative does not exist, image tags with the appropriate URI will be provided.

If you wish to use only 7-bit ASCII, then refer to the article on ASCII Output Codes.

# Determining Font Sizes

There is no set standard for BBCode font sizes. Message board vendors will use their own rules of determination, so using the same value for each will produce dissimilar results. Luckily, the representations on this page will only utilize one such transformation, thus lending themselves to the simplified requirement of a single lookup:

Whenever you see "[size=x]", the "x" should be replaced by…

• 0 if using IPB 2.1.7, MyBB, or vBulletin
• 10 if using phpBB
• 6pt if using SMF

These are based on the default skins for the above vendors.

# Unsupported Tags

If you find that a specific message board doesn't support one or more of the tags provided, then you should use the more accommodating ASCII Output Codes instead.

# Individual Characters

 Hex: 01 Name: "Recursive n" BBCode: [font=courier new][i]n[/i][/font] Hex: 02 Name: "Recursive u" BBCode: u Hex: 03 Name: "Recursive v" BBCode: v Hex: 04 Name: "Recursive w" BBCode: w Hex: 05 Name: "Convert" BBCode: [font=courier new]►[/font] Hex: 06 Name: "Square Up" BBCode: [img]http://tibasicdev.wikidot.com/local--files/83lgfont/06h_LsqUp.gif[/img] Hex: 07 Name: "Square Down" BBCode: [img]http://tibasicdev.wikidot.com/local--files/83lgfont/07h_LsqDown.gif[/img] Hex: 08 Name: "Integral" BBCode: [font=courier new]∫[/font] Hex: 09 Name: "Cross" BBCode: [font=verdana]×[/font] Hex: 0A Name: "Box Icon" BBCode: [font=courier new]▫[/font] Hex: 0B Name: "Cross Icon" BBCode: [font=arial][size=x]+[/size][/font] (?) Hex: 0C Name: "Dot Icon" BBCode: [font=courier new]·[/font] Hex: 0D Name: "Subscript T" BBCode: [font=verdana][size=x]т[/size][/font] (?) Hex: 0E Name: "Cube Root" BBCode: [font=verdana]³[/font] Hex: 0F Name: "Hexadecimal F" BBCode: [font=verdana][b]F[/b][/font] Hex: 10 Name: "Root" BBCode: [font=arial]√[/font] Hex: 11 Name: "Inverse" BBCode: [font=courier new]‾¹[/font] Hex: 12 Name: "Square" BBCode: [font=verdana]²[/font] Hex: 13 Name: "Angle" BBCode: [img]http://tibasicdev.wikidot.com/local--files/83lgfont/13h_Langle.gif[/img] Hex: 14 Name: "Degree" BBCode: [font=times new roman]°[/font] Hex: 15 Name: "Radian" BBCode: [font=verdana][sup]r[/sup][/font] Hex: 16 Name: "Transpose" BBCode: [font=arial][sup]т[/sup][/font] Hex: 17 Name: "Less Than or Equal To" BBCode: [font=verdana]≤[/font] Hex: 18 Name: "Not Equal To" BBCode: [font=verdana]≠[/font] Hex: 19 Name: "Greater Than or Equal To" BBCode: [font=verdana]≥[/font] Hex: 1A Name: "Negation" BBCode: [font=courier new]‾[/font] Hex: 1B Name: "Exponent" BBCode: [font=verdana][size=x]E[/size][/font] (?) Hex: 1C Name: "Store" BBCode: [font=courier new]→[/font] Hex: 1D Name: "Ten" BBCode: [font=courier new][size=x]10[/size][/font] (?) Hex: 1E Name: "Up Arrow" BBCode: [font=times new roman]↑[/font] Hex: 1F Name: "Down Arrow" BBCode: [font=times new roman]↓[/font] Hex: 20 Name: "Space" BBCode: [font=courier new]░[/font] Hex: 21 Name: "Exclamation Mark" BBCode: ! Hex: 22 Name: "Quotation Mark" BBCode: [font=verdana]"[/font] Hex: 23 Name: "Pound Sign" BBCode: # Hex: 24 Name: "Fourth" BBCode: [font=verdana][sup]4[/sup][/font] Hex: 25 Name: "Percent Sign" BBCode: % Hex: 26 Name: "Ampersand" BBCode: [font=arial]&[/font] Hex: 27 Name: "Apostrophe" BBCode: ' Hex: 28 Name: "Left Parenthesis" BBCode: ( Hex: 29 Name: "Right Parenthesis" BBCode: ) Hex: 2A Name: "Asterisk" BBCode: [font=verdana]*[/font] Hex: 2B Name: "Plus Sign" BBCode: + Hex: 2C Name: "Comma" BBCode: [font=times new roman],[/font] Hex: 2D Name: "Dash" BBCode: − Hex: 2E Name: "Period" BBCode: . Hex: 2F Name: "Slash" BBCode: / Hex: 30 Name: "0" BBCode: 0 Hex: 31 Name: "1" BBCode: 1 Hex: 32 Name: "2" BBCode: 2 Hex: 33 Name: "3" BBCode: 3 Hex: 34 Name: "4" BBCode: 4 Hex: 35 Name: "5" BBCode: 5 Hex: 36 Name: "6" BBCode: 6 Hex: 37 Name: "7" BBCode: 7 Hex: 38 Name: "8" BBCode: 8 Hex: 39 Name: "9" BBCode: 9 Hex: 3A Name: "Colon" BBCode: : Hex: 3B Name: "Semicolon" BBCode: [font=times new romain];[/font] Hex: 3C Name: "Less Than" BBCode: < Hex: 3D Name: "Equal To" BBCode: = Hex: 3E Name: "Greater Than" BBCode: > Hex: 3F Name: "Question Mark" BBCode: ? Hex: 40 Name: "At Sign" BBCode: [font=courier new]@[/font] Hex: 41 Name: "Capital A" BBCode: A Hex: 42 Name: "Capital B" BBCode: B Hex: 43 Name: "Capital C" BBCode: C Hex: 44 Name: "Capital D" BBCode: D Hex: 45 Name: "Capital E" BBCode: E Hex: 46 Name: "Capital F" BBCode: F Hex: 47 Name: "Capital G" BBCode: G Hex: 48 Name: "Capital H" BBCode: H Hex: 49 Name: "Capital I" BBCode: I Hex: 4A Name: "Capital J" BBCode: J Hex: 4B Name: "Capital K" BBCode: K Hex: 4C Name: "Capital L" BBCode: L Hex: 4D Name: "Capital M" BBCode: M Hex: 4E Name: "Capital N" BBCode: N Hex: 4F Name: "Capital O" BBCode: O Hex: 50 Name: "Capital P" BBCode: P Hex: 51 Name: "Capital Q" BBCode: Q Hex: 52 Name: "Capital R" BBCode: R Hex: 53 Name: "Capital S" BBCode: S Hex: 54 Name: "Capital T" BBCode: T Hex: 55 Name: "Capital U" BBCode: U Hex: 56 Name: "Capital V" BBCode: V Hex: 57 Name: "Capital W" BBCode: W Hex: 58 Name: "Capital X" BBCode: X Hex: 59 Name: "Capital Y" BBCode: Y Hex: 5A Name: "Capital Z" BBCode: Z Hex: 5B Name: "Theta" BBCode: [font=arial][i]θ[/i][/font] Hex: 5C Name: "Backslash" BBCode: \ Hex: 5D Name: "Right Bracket" BBCode: ] Hex: 5E Name: "Caret" BBCode: ^ Hex: 5F Name: "Underscore" BBCode: _ Hex: 60 Name: "Backquote" BBCode: [font=verdana]‘[/font] Hex: 61 Name: "Small A" BBCode: a Hex: 62 Name: "Small B" BBCode: b Hex: 63 Name: "Small C" BBCode: c Hex: 64 Name: "Small D" BBCode: d Hex: 65 Name: "Small E" BBCode: e Hex: 66 Name: "Small F" BBCode: f Hex: 67 Name: "Small G" BBCode: g Hex: 68 Name: "Small H" BBCode: h Hex: 69 Name: "Small I" BBCode: i Hex: 6A Name: "Small J" BBCode: j Hex: 6B Name: "Small K" BBCode: k Hex: 6C Name: "Small L" BBCode: l Hex: 6D Name: "Small M" BBCode: m Hex: 6E Name: "Small N" BBCode: n Hex: 6F Name: "Small O" BBCode: o Hex: 70 Name: "Small P" BBCode: p Hex: 71 Name: "Small Q" BBCode: q Hex: 72 Name: "Small R" BBCode: r Hex: 73 Name: "Small S" BBCode: s Hex: 74 Name: "Small T" BBCode: t Hex: 75 Name: "Small U" BBCode: u Hex: 76 Name: "Small V" BBCode: v Hex: 77 Name: "Small W" BBCode: w Hex: 78 Name: "Small X" BBCode: x Hex: 79 Name: "Small Y" BBCode: y Hex: 7A Name: "Small Z" BBCode: z Hex: 7B Name: "Left Brace" BBCode: { Hex: 7C Name: "Vertical Bar" BBCode: | Hex: 7D Name: "Right Brace" BBCode: } Hex: 7E Name: "Tilde" BBCode: [font=arial]~[/font] Hex: 7F Name: "Inverse Equal To" BBCode: [img]http://tibasicdev.wikidot.com/local--files/83lgfont/7Fh_LinvEQ.gif[/img] Hex: 80 Name: "Subscript 0" BBCode: [font=courier new][size=x]0[/size][/font] (?) Hex: 81 Name: "Subscript 1" BBCode: [font=courier new][size=x]1[/size][/font] Hex: 82 Name: "Subscript 2" BBCode: [font=courier new][size=x]2[/size][/font] Hex: 83 Name: "Subscript 3" BBCode: [font=courier new][size=x]3[/size][/font] Hex: 84 Name: "Subscript 4" BBCode: [font=courier new][size=x]4[/size][/font] Hex: 85 Name: "Subscript 5" BBCode: [font=courier new][size=x]5[/size][/font] Hex: 86 Name: "Subscript 6" BBCode: [font=courier new][size=x]6[/size][/font] Hex: 87 Name: "Subscript 7" BBCode: [font=courier new][size=x]7[/size][/font] Hex: 88 Name: "Subscript 8" BBCode: [font=courier new][size=x]8[/size][/font] Hex: 89 Name: "Subscript 9" BBCode: [font=courier new][size=x]9[/size][/font] Hex: 8A Name: "Capital A Acute" BBCode: Á Hex: 8B Name: "Capital A Grave" BBCode: À Hex: 8C Name: "Capital A Caret" BBCode: Â Hex: 8D Name: "Capital A Diaeresis" BBCode: Ä Hex: 8E Name: "Small A Acute" BBCode: á Hex: 8F Name: "Small A Grave" BBCode: à Hex: 90 Name: "Small A Caret" BBCode: â Hex: 91 Name: "Small A Diaeresis" BBCode: ä Hex: 92 Name: "Capital E Acute" BBCode: É Hex: 93 Name: "Capital E Grave" BBCode: È Hex: 94 Name: "Capital E Caret" BBCode: Ê Hex: 95 Name: "Capital E Diaeresis" BBCode: Ë Hex: 96 Name: "Small E Acute" BBCode: é Hex: 97 Name: "Small E Grave" BBCode: è Hex: 98 Name: "Small E Caret" BBCode: ê Hex: 99 Name: "Small E Diaeresis" BBCode: ë Hex: 9A Name: "Capital I Acute" BBCode: Í Hex: 9B Name: "Capital I Grave" BBCode: Ì Hex: 9C Name: "Capital I Caret" BBCode: Î Hex: 9D Name: "Capital I Diaeresis" BBCode: Ï Hex: 9E Name: "Small I Acute" BBCode: í Hex: 9F Name: "Small I Grave" BBCode: ì Hex: A0 Name: "Small I Caret" BBCode: î Hex: A1 Name: "Small I Diaeresis" BBCode: ï Hex: A2 Name: "Capital O Acute" BBCode: Ó Hex: A3 Name: "Capital O Grave" BBCode: Ò Hex: A4 Name: "Capital O Caret" BBCode: Ô Hex: A5 Name: "Capital O Diaeresis" BBCode: Ö Hex: A6 Name: "Small O Acute" BBCode: ó Hex: A7 Name: "Small O Grave" BBCode: ò Hex: A8 Name: "Small O Caret" BBCode: ô Hex: A9 Name: "Small O Diaeresis" BBCode: ö Hex: AA Name: "Capital U Acute" BBCode: Ú Hex: AB Name: "Capital U Grave" BBCode: Ù Hex: AC Name: "Capital U Caret" BBCode: Û Hex: AD Name: "Capital U Diaeresis" BBCode: Ü Hex: AE Name: "Small U Acute" BBCode: ú Hex: AF Name: "Small U Grave" BBCode: ù Hex: B0 Name: "Small U Caret" BBCode: û Hex: B1 Name: "Small U Diaeresis" BBCode: ü Hex: B2 Name: "Capital C Cedilla" BBCode: Ç Hex: B3 Name: "Small C Cedilla" BBCode: ç Hex: B4 Name: "Capital N Tilde" BBCode: Ñ Hex: B5 Name: "Small N Tilde" BBCode: ñ Hex: B6 Name: "Accent" BBCode: [font=courier new]´[/font] Hex: B7 Name: "Grave" BBCode: [font=courier new][/font] Hex: B8 Name: "Diaeresis" BBCode: [font=courier new]¨[/font] Hex: B9 Name: "Inverted Question Mark" BBCode: ¿ Hex: BA Name: "Inverted Exclamation Mark" BBCode: ¡ Hex: BB Name: "Small Alpha" BBCode: [font=courier new]α[/font] Hex: BC Name: "Small Beta" BBCode: [font=verdana]β[/font] Hex: BD Name: "Small Gamma" BBCode: [font=times new roman]γ[/font] Hex: BE Name: "Capital Delta" BBCode: [font=times new roman][size=x]∆[/size][/font] (?) Hex: BF Name: "Small Delta" BBCode: [font=times new roman]δ[/font] Hex: C0 Name: "Small Epsilon" BBCode: [font=verdana]ε[/font] Hex: C1 Name: "Left Bracket" BBCode: [ Hex: C2 Name: "Small Lambda" BBCode: [font=times new roman]λ[/font] Hex: C3 Name: "Small Mu" BBCode: [font=verdana]μ[/font] Hex: C4 Name: "Small Pi" BBCode: [font=times new roman]π[/font] Hex: C5 Name: "Small Rho" BBCode: [font=courier new]ρ[/font] Hex: C6 Name: "Capital Sigma" BBCode: [font=arial]Σ[/font] Hex: C7 Name: "Small Sigma" BBCode: [font=arial]σ[/font] Hex: C8 Name: "Small Tau" BBCode: [font=times new roman]τ[/font] Hex: C9 Name: "Small Phi" BBCode: [font=times new roman]φ[/font] Hex: CA Name: "Capital Omega" BBCode: [font=times new roman]Ω[/font] Hex: CB Name: "X Mean" BBCode: [img]http://tibasicdev.wikidot.com/local--files/83lgfont/CBh_LxMean.gif[/img] Hex: CC Name: "Y Mean" BBCode: [img]http://tibasicdev.wikidot.com/local--files/83lgfont/CCh_LyMean.gif[/img] Hex: CD Name: "Superscript X" BBCode: [font=times new roman][sup]×[/sup][/font] Hex: CE Name: "Ellipsis" BBCode: [font=verdana]…[/font] Hex: CF Name: "Left Pointing Triangle" BBCode: [font=courier new]◄[/font] Hex: D0 Name: "Block" BBCode: [font=courier new]▪[/font] Hex: D1 Name: "Per" BBCode: [img]http://tibasicdev.wikidot.com/local--files/83lgfont/D1h_Lper.gif[/img] Hex: D2 Name: "Hyphen" BBCode: - Hex: D3 Name: "Area" BBCode: [font=verdana]²[/font] Hex: D4 Name: "Temperature" BBCode: [font=arial]°[/font] Hex: D5 Name: "Cube" BBCode: [font=verdana]³[/font] Hex: D6 Name: "Enter" BBCode: n/a Hex: D7 Name: "Imaginary I" BBCode: [font=times new roman][i]i[/i][/font] Hex: D8 Name: "P Hat" BBCode: [img]http://tibasicdev.wikidot.com/local--files/83lgfont/D8h_Lphat.gif[/img] Hex: D9 Name: "Small Chi" BBCode: [font=times new roman]χ[/font] Hex: DA Name: "Stat F" BBCode: [img]http://tibasicdev.wikidot.com/local--files/83lgfont/DAh_LstatF.gif[/img] Hex: DB Name: "Natural Logarithm E" BBCode: [font=times new roman][i]e[/i][/font] Hex: DC Name: "List Capital L" BBCode: [font=arial][size=x]L[/size][/font] (?) Hex: DD Name: "Finance Capital N" BBCode: [font=arial][b]N[/b][/font] Hex: DE Name: "Two Right Parentheses" BBCode: )) Hex: DF Name: "Block Arrow" BBCode: [img]http://tibasicdev.wikidot.com/local--files/83lgfont/DFh_LblockArrow.gif[/img] Hex: E0 Name: "Cursor Overwrite" BBCode: [img]http://tibasicdev.wikidot.com/local--files/83lgfont/E0h_LcurO.gif[/img] Hex: E1 Name: "Cursor Overwrite Second" BBCode: [img]http://tibasicdev.wikidot.com/local--files/83lgfont/E1h_LcurO2.gif[/img] Hex: E2 Name: "Cursor Overwrite Capital A" BBCode: [img]http://tibasicdev.wikidot.com/local--files/83lgfont/E2h_LcurOcapA.gif[/img] Hex: E3 Name: "Cursor Overwrite Small A" BBCode: [img]http://tibasicdev.wikidot.com/local--files/83lgfont/E3h_LcurOa.gif[/img] Hex: E4 Name: "Cursor Insert" BBCode: [img]http://tibasicdev.wikidot.com/local--files/83lgfont/E4h_LcurI.gif[/img] Hex: E5 Name: "Cursor Insert Second" BBCode: [img]http://tibasicdev.wikidot.com/local--files/83lgfont/E5h_LcurI2.gif[/img] Hex: E6 Name: "Cursor Insert Capital A" BBCode: [img]http://tibasicdev.wikidot.com/local--files/83lgfont/E6h_LcurIcapA.gif[/img] Hex: E7 Name: "Cursor Insert Small A" BBCode: [img]http://tibasicdev.wikidot.com/local--files/83lgfont/E7h_LcurIa.gif[/img] Hex: E8 Name: "Graph Line" BBCode: [img]http://tibasicdev.wikidot.com/local--files/83lgfont/E8h_LGline.gif[/img] Hex: E9 Name: "Graph Thick" BBCode: [img]http://tibasicdev.wikidot.com/local--files/83lgfont/E9h_LGthick.gif[/img] Hex: EA Name: "Graph Above" BBCode: [img]http://tibasicdev.wikidot.com/local--files/83lgfont/EAh_LGabove.gif[/img] Hex: EB Name: "Graph Below" BBCode: [img]http://tibasicdev.wikidot.com/local--files/83lgfont/EBh_LGbelow.gif[/img] Hex: EC Name: "Graph Path" BBCode: [img]http://tibasicdev.wikidot.com/local--files/83lgfont/ECh_LGpath.gif[/img] Hex: ED Name: "Graph Animate" BBCode: [img]http://tibasicdev.wikidot.com/local--files/83lgfont/EDh_LGanimate.gif[/img] Hex: EE Name: "Graph Dot" BBCode: [img]http://tibasicdev.wikidot.com/local--files/83lgfont/EEh_LGdot.gif[/img] Hex: EF Name: "Up Block" BBCode: [img]http://tibasicdev.wikidot.com/local--files/83lgfont/EFh_LUpBlk.gif[/img] Hex: F0 Name: "Down Block" BBCode: [img]http://tibasicdev.wikidot.com/local--files/83lgfont/F0h_LDnBlk.gif[/img] Hex: F1 Name: "Cursor Full" BBCode: [img]http://tibasicdev.wikidot.com/local--files/83lgfont/F1h_LcurFull.gif[/img] Hex: F2 Name: "Dollar Sign" BBCode: [font=arial][/font] Hex: F3 Name: "Square Up" BBCode: [img]http://tibasicdev.wikidot.com/local--files/83lgfont/F3h_LsqUp.gif[/img] Hex: F4 Name: "Sharp S" BBCode: [font=verdana][b]ß[/b][/font] Hex: F5 Name: "MathPrint Mixed Fraction Separator" BBCode: [font=verdana][b]˽[/b][/font] Hex: F6 Name: "MathPrint Fraction Slash" BBCode: [img]http://tibasicdev.wikidot.com/local--files/83lgfont/F6h_LMPfracSlash.gif[/img] Hex: F7 Name: "MathPrint Entry Box" BBCode: [img]http://tibasicdev.wikidot.com/local--files/83lgfont/F7h_LMPentryBox.gif[/img] Command Summary Sets a condition for a line or several lines to be executed. Command Syntax If condition :statement :If condition Then :EndIf Menu Location Starting in the program editor: • Press F2 to enter the Control menu. • Press 1 to paste If. This command works on all calculators. 2 bytes for If or If..Then; 2 bytes for Else; 2 bytes for ElseIf..Then; 2 bytes for EndIf. The If command is the most basic tool in programming. The idea is simple: it checks a condition, and then does something only if the condition is true. ## If by itself With the simplest use of If, the line after it will be skipped if the condition is false. In the code below, if x really is 4, then the check x=4 is true, so the program will display "x equals 4". If x is not 4, then the check will be false, so Text "x equals 4" will be skipped. Nothing will be displayed. :If x=4 : Text "x equals 4"  ## If..Then..EndIf To have multiple lines of code depend on the same condition, use the If condition Then..EndIf syntax. Every line before the EndIf will be skipped if the condition is false. In the following example, both true→xisfour and Text "x equals 4" depend on the condition x=4. :If x=4 Then : true→xisfour : Text "x equals 4" :EndIf  ## If..Then..Else..EndIf Often, you want to do one thing if the condition is true, and another if the condition is false. The way to do this is to insert an Else into the If..EndIf block. Everything between If condition Then and Else is what happens when the condition is true. Everything between Else and EndIf is what happens when the condition is false. Note: the Else command is also used inside Try..EndTry blocks. In the following example, "x is 4" will be displayed if x=4, and "x is not 4" otherwise. :If x=4 Then : Text "x is 4" :Else : Text "x is not 4" :EndIf  ## ElseIf..Then Finally, you can use ElseIf condition Then, inside an If..EndIf block, to consider several conditions at the same time. The way this works is: first the basic If condition is checked. If it's true, then the code just after If runs. If that condition was false, but there's an ElseIf, the ElseIf's condition is checked. If it's true, then the code just after the ElseIf runs. If that condition was false too, the program goes on to check the next ElseIf (if there is one), and so forth. You can also include a final Else (optionally) which will only run if no condition is met. For example: :If x=4 Then : Text "x is 4" :ElseIf x=5 Then : Text "x is 5" :ElseIf x=6 Then : Text "x is 6" :Else : Text "x is neither 4, 5, nor 6" :EndIf  ## Conditions What kind of conditions are possible? Any command that returns a logical value — true or false — is acceptable. This includes: • Relational operators: =, , >, , <, and • Logical operators: and, or, xor, not • Any advanced test command: pxlTest(), isPrime(), and others. • A variable that contains one of the values true or false, or a function that returns them. Of course, these can also be combined: for example, isPrime(x) and x≠2 is a valid condition. # Optimization Use If without a Then or EndIf for only one command; use Then and EndIf otherwise. In addition, the when() command can often replace If. # Error Conditions 20 - A test did not resolve to TRUE or FALSE happens when the condition is indeterminate, or the wrong data type. 280 - Else and ElseIf invalid outside If..Then block happens when Else or ElseIf are used outside If..EndIf. 730 - Missing start or end of block syntax happens when the If-Thens and EndIfs don't match up correctly. 740 - Missing Then in the If..EndIf block happens when a Then is missing. # Related Commands These are the settings that can be used with setMode() and getMode(), with a brief explanation. The 'Number' field refers to an alternate string that can be used for compatibility with other language versions. Tables are also given for the setGraph() and setTable() commands. # Table for setMode() and getMode() "Graph" "1" The type of equations that can be graphed Setting Number Meaning "FUNCTION" "1" Graphs functions of the form y(x) by connecting points (x,y(x)) for all x. "PARAMETRIC" "2" Graphs functions of the form x(t), y(t) by connecting points (x(t),y(t)) for a range of t. "POLAR" "3" Graphs functions r(θ) where θ is the angle with the x-axis and r is the radius. "SEQUENCE" "4" Graphs possibly recursive functions u(n) in several ways. "3D" "5" Graphs functions of the form z(x,y) on 3-dimensional x, y, and z axes. "DIFF EQUATIONS" "6" Graphs solutions and slope fields for simple differential equations. "FIX #" "1"-"13" Displays a fixed number of digits after the decimal, # can be 0 to 12. "FLOAT" "14" Equivalent to "FLOAT 12". "FLOAT #" "15"-"26" Displays up to # digits total, omitting final zeros after the decimal. # can be 1 to 12. "RADIAN" "1" Most common for mathematicians: a full circle is equal to 2π radians. "DEGREE" "2" Common for non-mathematicians: a full circle is equal to 360 degrees. "GRADIAN" "3" (Requires AMS 3.10) An uncommon format in which a full circle is equal to 400 gradians. "NORMAL" "1" Most numbers are displayed in the normal way; large numbers use scientific notation. "SCIENTIFIC" "2" All numbers are displayed as mantissa*10^exponent (E stands in place of *10^). "ENGINEERING" "3" Similar to scientific notation, except exponent must be a multiple of 3. "REAL" "1" The Non-real result error happens if the result of an expression is complex. "RECTANGULAR" "2" Complex numbers are written as x+yi. "POLAR" "3" Complex numbers are written as reθi. "RECTANGULAR" "1" Vectors are displayed just like any other matrix. "CYLINDRICAL" "2" Vectors are displayed in [r ∠ θ] or [r ∠ θ z] format. "SPHERICAL" "3" Vectors are displayed in [r ∠ θ] or [r ∠ θ ∠ φ] format. "OFF" "1" Pretty print is disabled: formulas are displayed the way they are typed. "ON" "2" Pretty print is enabled: formulas are displayed the way they would be on paper. "FULL" "1" The entire screen is devoted to one task. "TOP-BOTTOM" "2" The screen is split into top and bottom halves devoted to separate applications. "LEFT-RIGHT" "3" The screen is split into left and right halves. (Apart from the defaults: "Home", "Graph", etc. the apps depend on what's installed, and aren't numbered.) (Apart from the defaults: "Home", "Graph", etc. the apps depend on what's installed, and aren't numbered.) "1" "1" There is only one graphing mode. "2" "2" There are two graphing modes. (See the "Graph" setting for the options here — they are the same) "1:1" "1" The two parts are equal. "1:2" "2" The second part is twice the size of the first. "2:1" "3" The first part is twice the size of the second. "AUTO" "1" Exact results stay exact except to prevent overflow; floating-point numbers stay in floating-point. "EXACT" "2" All numbers are automatically converted to exact integers or fractions "APPROXIMATE" "3" All calculations are done in floating-point, as on the TI-83 series calculators. "DEC" "1" Integers are displayed in the usual (decimal) base, in their entirety. "HEX" "2" The lowest 32 bits of an integer are displayed in hexadecimal (base 16). "BIN" "3" The lowest 32 bits of an integer are displayed in binary (base 2). "OFF" "1" Applications are selected through a popup menu. "ON" "2" Applications are selected through a graphic interface. # Table for setGraph() "Coordinates" "1" The coordinate system used for recording the cursor's location Setting Number Meaning "RECT" "1" The standard (x,y) coordinates are displayed and stored to xc and yc. "POLAR" "2" The polar (r,θ) coordinates are displayed and stored to rc and θc (standard coordinates are also stored). "OFF" "3" No coordinates are displayed, although the standard (x,y) coordinates are still stored. "SEQ" "1" Different equations are graphed one after the other. "SIMUL" "2" Different equations are graphed simultaneously. "OFF" "1" The grid is not displayed. "ON" "2" The grid is displayed. "OFF" "1" The axes are not displayed. "ON" "2" The axes are displayed. "AXES" (3D mode) "2" The axes are displayed. "BOX" (3D mode) "3" A 3D box is displayed outside the graph. "OFF" "1" The cursor is not displayed. "ON" "2" The cursor is displayed. "OFF" "1" The axes aren't labeled. "ON" "2" The axes are labeled. "TIME" "1" Each sequence is graphed with n on the x-axis and ui(n) on the y-axis. "WEB" "2" A web diagram of one sequence is graphed. "Custom" "3" The variables for the x-axis and y-axis can be selected. "RK" "1" Runge-Kutta is used to estimate solutions. "EULER" "2" Euler's method is used to estimate solutions. "SLPFLD" "1" A slope field is displayed. "DIRFLD" "2" A directed slope field is displayed. "FLDOFF" "3" No field is displayed. "TIME" "1" yi(t) is plotted against t. "Y1-VS-Y2" "2" y1(t) is plotted against y2(t). "T-VS-Y'" "3" t is plotted against yi'(t). "Y-VS-Y'" "4" yi(t) is plotted against yi'(t). "Y1-VS-Y2' "5" y1(t) is plotted against y2'(t). "Y1'-VS-Y2'" "6" y1'(t) is plotted against y2'(t). "WIRE FRAME" "1" A wire frame graph is displayed. "HIDDEN SURFACE" "2" A non-transparent 3D surface is displayed. "CONTOUR LEVELS" "3" The contours of a 3D graph are displayed. "WIRE AND CONTOUR" "4" A combination of wire frame and contour levels is displayed. "IMPLICIT PLOT" "5" The graph is plotted implicitly. # Table for setTable() "Graph <-> Table" "1" Source for automatic table values Setting Number Meaning "OFF" "1" Automatic table values are based on tblStart and Δtbl. "ON" "2" Automatic table values are the same as those used to graph the equation. "AUTO" "1" Use the automatic table values (as above) for the independent variable. "ASK" "2" Enter values for the independent variable manually, ignoring other table settings. Command Summary Changes one or more mode settings. Command Syntax • setMode(setting,value) • setMode({set1,val1,…}) Menu Location Starting in the program editor: • Press F6 to enter the Mode menu. • Select the desired setting to enter its submenu. • Select the desired value to paste setMode("setting", "value") This command works on all calculators. 3 bytes The setMode() command is used, mainly by programmers, to change mode settings (outside a program, of course, you can just select the settings in the MODE menu). When a setting is changed, it returns the old value of the setting. There are two ways to use the command: • setMode(setting,value) will change setting to value, and return the old value of setting. • setMode({set1,val1,…}) will change set1 to val1, set2 to val2, and so on, for any number of settings, and return a list in the same format of settings and their old values. The first format is used to change only one setting, and the second to change several settings. Both settings and values are identified by strings (not case-sensitive). All the strings involved are given in the Table of Mode Settings. An example of setMode(): setMode("Angle","DEGREE") "RADIAN" setMode({"Angle","RADIAN","Split Screen","FULL"}) {"Split Screen" "FULL" "Angle" "DEGREE"}  # Advanced Uses Unfortunately, the strings depend on language localization. For compatibility with other languages, there is an alternate identification for the settings and values: you can use a string containing a number identifying the setting or value (see the Table of Mode Settings). This is also shorter. As an example, the numerical version of the sample code above would be: setMode("3","2") "1" setMode({"3","1",8","1"}) {"8" "1" "3" "2"}  Use the output of the list version of setMode() to restore settings to what they were previously: :setMode({"Angle","RADIAN"})→oldmode ... :setMode(oldmode)  This works with the numerical or the verbose versions of the command; the output of the command will be in the same format as the input. # Error Conditions 130 - Argument must be a string happens when the data type of arguments is incorrect. 260 - Domain error happens when the string used to identify a setting is incorrect or misspelled. 430 - Invalid for the current mode settings happens when a setting depends on other settings that are incorrect (e.g. setting "Split 2 App" if "Split Screen" is "FULL"). 450 - Invalid in a function or current expression happens when setMode() is used in a function. # Related Commands # See Also Like Tic-Tac-To, Hangman is a game that almost everybody has played at some point in their life. The basic premise behind the game is that two people alternate turns, with one person picking a word, and then the second person trying to guess the word by selecting letters until they have either gotten the word or run out of chances. This game features some rather advanced string manipulation, as well as some good compression for storing the different pieces of the hangman character. Again, try out the game and try to understand and think through the code.  Table of Contents ## The Code :"ABCDEFGHIJKLMNOPQRSTUVWXYZ→Str0 :Repeat 33>length(Str1 :ClrHome :Disp "WORD? (32 CHARS) :Input "",Str1 :End :"?→Str2 :For(I,1,length(Str1 :sub(Str1,I,1 :If inString(Str0,Ans:"- :Str2+Ans→Str2 :End :sub(Ans,2,length(Ans)-1→Str2 :8→T :ClrHome :While Str1≠Str2 and T :Output(1,1,Str2 :.1{69,67,58,49,47,48,38,38 :Output(iPart(Ans(T)),10fPart(Ans(T)),sub("^^I--IO ",T,1 :Repeat 30<Ans and Ans<94 :getKey :End :If Ans=45:Goto Q :Ans-20-5int(.1Ans)-2(Ans>45→K :sub(Str0,Ans,1→Str3 :Output(7+(K>14),K+1-13(K>14),Ans :inString(Str1,Ans→I :T-not(Ans→T :While I :sub(sub(" "+Str2,1,I)+Str3+sub(Str2+" ",I+1,length(Str2)-I+1),2,length(Str2→Str2 :inString(Str1,Str3,I+1→I :End :End :Lbl Q :Pause "YOU "+sub("LOSE!WIN! ",1+5(Str1=Str2),5 :ClrHome  ## The Download In case you want to try the program on your calculator, you can download the program in .8xp format. Tic Tac To is a game that almost everybody has played at one point in their life, no matter who they are. The simple premise behind the game is to alternate turns placing pieces on the 3x3 game board until somebody gets 3-in-a-row or all nine spots on the game board are filled. This game best lends itself to a matrix variable, so that is what we decided to use for the game board. Of course, you can also use a list or string. Again, try out the game and try to understand and think through the code.  Table of Contents ## The Code :0→A:0identity(3→[A] :1-2int(2rand→B :"+++ :ClrHome :Disp Ans,Ans,Ans :Repeat 0 :Repeat Ans :.1getKey→K :End :If 2Ans=9:Goto Q :iPart(Ans)-6→C :10fPart(K)-1 :If max(2≤abs({C,Ans}-2:End :If [A](C,Ans:End :Output(C,Ans,sub("X O",B+2,1 :B→[A](C,Ans :For(C,0,1 :[A]T→[A] :For(D,1,3 :Matr►list([A],D,T :If min(∟T=B:Goto Q :End :If min(B=seq([A](abs(4C-X),X),X,1,3 :Goto Q :End :-B→B:IS>(A,9 :End :Lbl Q :"TIE! :If A≠9 :sub("X O",B+2,1)+" WINS! :If 2K≠9 :Pause Ans :ClrHome:"  ## The Download In case you want to try the program on your calculator, you can download the program in .8xp format. Memory is a simple "card" game where you flip over two cards each turn to try to get a matching pair. If they match, then the cards are removed from the playing field. If they don't match, the cards are just flipped back over. You continue playing until all of the cards are removed. The game playing field is a square 4x4 matrix, but you can increase this to a larger size if you like.  Table of Contents ## The Code :identity(4→[A] :cumSum(binomcdf(7,0 :augment(Ans,Ans→L1 :rand(16→L2 :SortA(L2,L1 :ClrHome :For(Y,1,4 :For(X,1,4 :Output(Y,2X,"? :L1(X+4Y+4→[A](Y,X :End:End :DelVar W :DelVar S1→Y :DelVar T1→X :For(A,1,8 :For(B,0,1 :Repeat K=21 and [A](Y,X)(Y≠S or X≠T :Output(Y,2X-1,"> :Repeat Ans :getKey→K :End :Output(Y,2X-1," :max(1,min(4,X+(Ans=26)-(Ans=24→X :max(1,min(4,Y+(K=34)-(K=25→Y :End :Output(Y,2X,sub("ABCDEFGH",[A](Y,X),1 :If not(B:Then :Y→S:X→T :End :End :rand(30 :If [A](Y,X)=[A](S,T:Then :0→[A](Y,X :Output(Y,2X," :0→[A](S,T :Output(S,2T," :Else :A-1→A :Output(Y,2X,"? :Output(S,2T,"? :End :W+1→W :End :Disp "Score: :Pause W :ClrHome:"  ## The Download In case you want to try the program on your calculator, you can download the program in .8xp format. Like the classic game minesweeper, the goal of Mine Field is to avoid hitting the mines. A new twist has been added, however, and you must maneuver the field around the mines to get to the star (the asterisk) on the other side. The game uses a simple 8x16 matrix to store the field, although you could use a list or string as well. You can play this game indefinitely, since all of the mines are randomly placed.  Table of Contents ## The Code :ClrHome :1→X:1→Y :DelVar [B]{8,16→dim([B] :6→[B](randInt(2,7),15 :6→[B](randInt(2,7),14 :For(A,1,8 :6→[B](A,randInt(2,15 :End :1→[B](4,16 :Output(Y,X,"> :Output(4,16,"* :Repeat [B](Y,X :Repeat Ans :getKey→G :End :Output(Y,X," // 1 space :X-(G=24 and X>1)+(G=26 and X<16→X :Y-(G=25 and Y>1)+(G=34 and Y<8→Y :Output(Y,X,"> :End :ClrHome :"YOU "+sub("WIN!!LOSE!",[B](Y,X),5  ## The Download In case you want to try the program on your calculator, you can download the program in .8xp format. Pong is a classic program for beginner programs to start out with, so we thought it was important to include it. The basic premise behind pong is you have to keep the ball ("O") in play by bouncing it back and forth against the walls, without letting it get by your paddle ("["). You can play this game indefinitely, but it does get monotonous after a while.  Table of Contents # The Code :3→A:4→X :1→S:1→T :randInt(1,8→Y :Repeat K=45 or X=1 and A≠Y :ClrHome :Output(A,1,"[ :Output(Y,X,"O :getKey→K :max(1,min(8,A+(Ans=34)-(Ans=25→A :T(Y>1 and Y<8)+(Y=1)-(Y=8→T :S(X>1 and X<16)+(X=1)-(X=16→S :X+Ans→X:Y+T→Y :End :Pause "Game Over! :ClrHome:"  # The Download In case you want to try the program on your calculator, you can download the program in .8xp format. The basic premise behind Maze Walkthrough is you have to make your way through the maze without touching any of the walls. This game is rather simple at its core, but it does feature a randomly generated maze each time, so it can be played indefinitely. It also is extremely compact, a good example of what you can do in a small number of bytes.  Table of Contents ## The Code :ClrHome :ClrDraw :AxesOff :ZStandard :Vertical Xmin :Horizontal Xmin :Horizontal Xmax :For(X,‾9,10 :randInt(‾8,8 :Line(X,Xmax,X,Ans :Line(X,Xmin,X,Ans-2 :End :3→X:3→Y:E3→S :Repeat K=45 or X=94 or pxl-Test(Y,X :Pxl-On(Y,X :Repeat Ans :getKey→K :End :Pxl-Off(Y,X :S-1→S :X+(K=26)-(K=24→X :Y+(K=34)-(K=25→Y :End :ClrDraw :Text(15,15,"You "+sub("Lose!Win! ",1+5(X=94),5 :Text(22,15,"Score: ",S :Pause :ClrDraw :ClrHome:"  ## The Download In case you want to try the program on your calculator, you can download the program in .8xp format. The basic premise behind Avalanche is to avoid the falling spikes ("V") by moving to the left or right, trying to see how long you can hold out for. It is somewhat more complex than Guess the Number, using nested loops, a list variable, and some fairly advanced optimizations. Try to understand the code, and actually put it in your calculator and try it out.  Table of Contents ## The Code :ClrHome :Disp "SPEED :Disp "1) SLOW :Disp "2) NORMAL :Disp "3) FAST :DelVar Z8→X :Repeat 2>abs(Ans-2 :getKey-91→S :End :ClrHome :Disp "SCORE: :Repeat K=45 or max(X=L1 :Output(8,1," // 16 spaces :2→F :seq(3I-int(3rand),I,1,5→L1 :Repeat K=45 or F=8 :getKey→K :min(15,max(2,X-(Ans=24)+(Ans=26→X :Output(8,Ans-1," O // 1 space :Output(F,1," // 16 spaces :F+1→F :For(I,1,5 :Output(Ans,L1(I),"V :End :Z+S→Z :Output(1,7,Ans :rand(4-S :End :End :DelVar L1ClrHome :Disp "YOUR SCORE: :Pause Z :ClrHome:"  ## The Download In case you want to try the program on your calculator, you can download the program in .8xp format. Guess the Number has been a classic program for most beginner programmers to start out with. This is because it features a rather simple concept and it is fairly easy to program. Because of this, we felt like it made sense to show you how it would translate into TI-Basic.  Table of Contents ## The Code This Guess the Number program features a guess tracker that keeps track of how many tries it took you to guess the number. The range for the numbers is 1 to 100. This can easily be altered by you if you want a larger range. In addition, you can have the user input their own desired range. If you go that route, though, you need to do some error checking to make sure that the user actually inputs a valid number within the allotted range. :ClrHome :Disp "Guess The Number :Disp "Range is 1-100 :DelVar TrandInt(1,E2→A :Repeat A=B :Input "Guess?",B :T+1→T :If A≠B :Disp "Too "+sub("HighLow ",1+4(A>B),4 :End :Disp "Good Guess! :Disp "Number of tries: :Pause T :ClrHome:"  ## The Explanation We first start the program out by clearing the home screen and then displaying the program name and the range that the user has to guess the number from. We are using Disp commands to display the program name and range because the Input command follows the same pattern as the Disp command when displaying text: text on the left and everything else on the right. We want to keep everything uniform and provide some continuity, so the Disp command made more sense than the Output command. After displaying the program name and range, we next need to setup the game variables. We will be using the T real variable to keep track of how many guesses the user takes, while the A real variable is the random number that the user will have to guess. The T variable starts out at zero because the user hasn't made any guesses at this point, so we were able to set it to zero by using the DelVar command. As the DelVar command doesn't need a colon after it, we can then place the randInt( command immediately after it. Note also that we used the small 'E' from scientific notation to get the number 100 instead of the number itself. :ClrHome :Disp "Guess The Number :Disp "Range is 1-100 :DelVar TrandInt(1,E2→A  Next we initialize the main program loop, where all the code inside the loop will be repeated until the user guesses the number. While we could have used any one of the three different loops available in TI-Basic (i.e. While, Repeat, or For), we are using a Repeat loop because it loops at least once. Consequently, this allowed us to not have to set the B variable before the loop started. :Repeat A=B  We now ask the user to input a guess for what they think the number is. We are using the Input command here because it has an optional text argument, which is more user-friendly than simply displaying what variable it is like with the Prompt command. After the user guesses a number, we then store that number into the B variable. :Input "Guess?",B  Next we increment the guess count by one. This is rather simple to understand and see, so there is no point in explaining it any further. :T+1→T  Now we get to the heart of the loop. After the user has guessed a number, we need to tell them whether their guess was too high or too low, so they can adjust it the next time around. As we don't want to display the message if the user has guessed the number, we put a conditional before the Disp command to check if the user guess is equal to the random number. When displaying the message, we first display the "Too" part that is common to both too high and too low and then concatenate the high or low part to it. We place the "High" and "Low" in the sub command as a string, and then get either part of the string as a substring depending on whether the guess is higher or lower than the random number. The "High" part will be displayed by default, while the "Low" part will be displayed if 'A>B' is true. As we don't have any more things to do inside the main program loop, we need to close the loop. When the End command of the Repeat loop is reached, the loop will check whether the condition is true or not. If 'A=B' is true, then the loop will end and program execution will continue after the loop. :If A≠B :Disp "Too "+sub("HighLow ",1+4(A>B),4 :End  Once the user has guessed the number, we display the congratulatory message "Good Guess!" and tell them how many tries it took them to guess the number. As the Disp command gives each argument its own line and the Pause command has an optional argument, we display the guess variable 'T' with the Pause command to save space. After that we then exit the program by clearing the screen and removing the "Done" message using a double quote. This part is important because the user doesn't want to have to clear the screen themselves, and it also makes the program look more professional if it cleans up after itself. :Disp "Good Guess! :Disp "Number of tries: :Pause T :ClrHome:"  ## The Download In case you want to try the program on your calculator, you can download the program in .8xp format. Before releasing your TI-Basic programs to the public, you should choose which license you want to release them under. A license for a TI-Basic program may seem like overkill to some people, but it is an important part of the program — it dictates what people are allowed to do with the program, including using the code or graphics in their own programs, distributing the program on the Internet, and even modifying the program. While there are literally hundreds of licenses available to choose from, the two most common licenses that are used are Copyright and GNU General Public License (GPL). Copyright is the traditional license, and it simply means that you retain all rights to the program. GPL is a version of copyleft, meaning that people can copy, distribute, and modify the program. The one condition, however, is that they then need to release their program under the GPL as well. In addition to copyright and GPL, another common license is Public Domain. This license is not really a license in the literal sense, but means that you want to release your program to the public and give up all rights related to it. Doing this causes the program to become public property, allowing anybody to do with it whatever they want. When enforcing a license, you usually include it in the documentation of the program. The license statement can be as thorough as you want, but a sentence or short paragraph is generally sufficient. You just want to state what license the program is under, and list any restrictions that you are putting on the program. You can also include a URL link to the license's website on the Internet. Here is an example of a typical copyright license: Copyright © 1996-2007, the ticalc.org project. All rights reserved.  # Thoughts to Consider Regardless of what license you release your program under, an important consideration is how others might be able to learn from your code. This mostly applies to beginner programmers who are just starting out learning TI-Basic, and don't have very good coding habits and practices established yet, but it can certainly apply to any TI-Basic programmer. It is a good idea to allow others to study your code, and use the techniques and concepts in their programs, because that increases the quality of TI-Basic programs being released. This also makes sense on a practical level because there are generally only a few ways to accomplish certain tasks in TI-Basic, such as movement or subprograms. Even if you come up with a truly original technique (such as using the binompdf( and binomcdf( commands as substitutes for seq(), arguably the best thing to do is to share it with the TI-Basic community. You can ask that others attribute it to you, or simply release it completely with no strings attached. Of course, if somebody uses a technique or concept from your program, a kind gesture on their part is to give you credit for it. This isn't a strict requirement — you aren't going to have their program removed from a program archive if they don't list you in the credits — but it does go a long ways towards maintaining the open and collaborative nature of the TI-Basic community. The only real exception to this is using somebody else's graphics, in which case you do need to get their permission to use their graphics in your game. However, if you don't plan on releasing your game to the TI-Basic community, but instead just keeping it to yourself and your friends, then it doesn't really matter. Command Summary Performs a χ² goodness-of-fit test. Command Syntax χ²GOF-Test(observed,expected,df) Menu Location While editing a program, press: 1. STAT to access the statistics menu. 2. LEFT to access the tests submenu. 3. ALPHA D to select χ²GOF-Test(. (outside the program editor, this will select the χ²GOF-Test… interactive solver) TI-84+/SE, OS 2.30 or higher 2 bytes The χ²GOF-Test( command performs a χ² goodness-of-fit test. Given an expected ideal distribution of a variable across several categories, and a sample from this variable, it tests the hypothesis that the variable actually fits the ideal distribution. As a special case, you could take the ideal distribution to be evenly divided across all categories. Then, the goodness-of-fit test will test the hypothesis that the variable is independent of the category. The command takes three arguments: • An observed list with an element for each category: the element records the number of times this category appeared in the sample. • An expected list with an element for each category: the element records the frequency with which the category was expected to appear. • The degrees of freedom — usually taken to be one less than the number of categories. The output is two-fold: • The test statistic, χ². If the null hypothesis (that the variable fits the distribution) is true, this should be close to 1. • The probability, p, of the observed distribution assuming the null hypothesis. If this value is low (usually, if it's lower than .05, or lower than .01) this is sufficient evidence to reject the null hypothesis, and conclude that the variable fits a different distribution. # Sample Problem Working as a sales clerk, you're wondering if the number of customers depends on the day of week. You've taken a count of the number of customers every day for a week: 17 on Monday, 21 on Tuesday, 18 on Wednesday, 10 on Thursday, 24 on Friday, 28 on Saturday, and 24 on Sunday. Store this observed count: {17,21,18,10,24,28,24} to L1. There were a total of sum(L1)=142 customers. So the expected number of customers on each day was 142/7. Store all the expected counts: {142/7,142/7,142/7,142/7,142/7,142/7,142/7} to L2 (as a shortcut, you can store 142/7{1,1,1,1,1,1,1}). Since there are 7 days, there are 6 (one less) degrees of freedom. So the resulting command is χ²GOF-Test(L1,L2,6). The output will give a χ² of 10.32394366, and a p value of 0.1116563376. This is higher than 5%, so the test is not significant on a 95 percent level. It's perfectly possible, in other words, that the number of customers is independent of the day of week. (Note that in this case, if you suspected the number of customers to be higher on weekends, you could use a more sensitive test for only two categories: 2-SampTTest) # Advanced Uses The χ²GOF-Test( command is only on TI-84 Plus and newer calculator models. However, it's possible to use the χ²cdf( command to simulate it on the other calculators: see the χ² Goodness-of-fit Test routine. # Formulas The formula for calculating the test statistic is as follows (Oi is the observed count of the ith category, and Ei is the expected count): (1) \begin{align} \chi_{n-1}^2 = \sum_{i=1}^n \frac{(O_i-E_i)^2}{E_i} \end{align} The p-value, then, is the probability that the χ² statistic would be this high, using the χ²cdf( command with the appropriate value for degrees of freedom. # Error Conditions • ERR:DIM MISMATCH is thrown if the two lists are of different length. • ERR:DOMAIN is thrown if they only have one element, or if df is not a positive integer. # Related Commands # See Also Command Summary Returns the whole number part of a division. Command Syntax intDiv(dividend,divisor) Menu Location This command can't be found in any menu besides the command catalog. This command works on all calculators. 1 byte The integer division command, intDiv(a,b) returns the whole number portion of a/b: this is equal to iPart(a/b). Although this operation is most useful for dividing whole numbers, this definition works for any number, whole or decimal, real or complex. :intDiv(125,3) 41 :intDiv(-125,3) -41 :intDiv(125,π) 39  # Advanced Uses The intDiv() command also works for lists and matrices. Used with a list or matrix and a number, intDiv() is applied to the number paired with every element of the list or matrix. Used with two lists or two matrices, which must match in size, intDiv() is applied to matching elements of the list or matrix. Use intDiv() and remain() for the quotient and remainder results of long division, respectively. # Optimization Constructions like iPart(a/b) should be replaced with intDiv(a,b): this is smaller and faster. # Error Conditions 240 - Dimension mismatch happens when two list or matrix arguments don't match in size. Division by zero does not throw an error; an undefined value is returned instead. # Related Commands NOTE: Due to the limitations of the wiki markup language, the {cmd} command on this page does not appear as it would on the calculator. See Wiki Markup Limitations for more information.

Menu Location

This command can't be found in any menu besides the command catalog.

This command works on all calculators.

(1)
$${eqn}$$

{$num} - {$error} happens when {cause}. This page is a guide to the includable pages with their parameters. See the wiki syntax description for an explanation of including pages. # Includes for home pages • Members for the list of when members joined TI-83 Section: TI-68k Section: # Includes for command, routine and program pages TI-83 Section: TI-68k Section: • 68k Command Infobox • Error Conditions • 68k-error • num = error number (e.g. "260") • error = error description (e.g. "Domain Error") • cause = error cause (e.g. "the argument is not in the range 1-99") # Miscellaneous Includes • Tablet for the programs in the archives • Tablet HELP for instructions on how to use the infobox. • You probably don't need to worry about the Backend. • math or 68k-math for math formulas in the right background color. • eqn = LaTeX equation • markup or 68k-markup for a markup limitations warning. • cmd = command to issue a warning about • next-prev for linking to next/previous pages of a tutorial. • prevpage = linkable name of previous page • prevtitle = title of previous page • tocpage = linkable name of table of contents page • toctitle = title of table of contents • nextpage = linkable name of next page • nexttitle = title of next page • stub for a page with minimal content. • cleanup for a page that needs to be cleaned up. • cid for a page that is currently in development • extra = extra information that will be displayed; • You probably don't need to worry about the cid-backend. • development for a page that is a member of the development cycle. Tunnel Racer is a game of reaction in which you race through a twisting tunnel, trying to avoid crashing. By pressing the arrow keys, the player moves left and right. ESC exits the game. This game showcases the following techniques and ideas: # The Code :tunnel() :Prgm :Local center,height,player,temp,wall,score,shift1,shift2,key,dir,i,modeset,graphset,graphopt :StoGDB graphset :setMode({"Graph","FUNCTION","Split Screen","FULL","Exact/Approx","AUTO","Base","DEC"})→modeset :{}→graphopt :setGraph("Grid","OFF")→graphopt[1] :setGraph("Axes","OFF")→graphopt[2] :setGraph("Labels","OFF")→graphopt[3] :ClrDraw :ClrGraph :FnOff :PlotsOff :getConfg()[14]/2-1→center :when(center=119,98,72)→height :For i,center,18,-1 : PxlVert center+i : PxlVert center-i :EndFor :NewPic [3,0;2,1;3,1;1,2;2,2;3,2;2,3;3,3;3,4],player :NewPic [0,0;0,35],shift1 :NewPic [0,0;0,1;0,35;0,36],shift2 :center-17→wall :0→score :0→dir :0→key :0→d : :While not pxlTest(height,center) and key≠264 : While not pxlTest(height,center) and key≠264 and d=0 : score+1→score : Stopic temp : RplcPic temp,1 : RclPic player,height,center-2 : If rand(2)=1 Then : wall-1→wall : XorPic shift1,0,wall : Else : XorPic shift1,0,wall : wall+1→wall : EndIf : getKey()→key : when(key=340,1,when(key=337,-1,0))→d : EndWhile : While not pxlTest(height,center) and key≠264 and d>0 : score+1→score : StoPic temp,0,1 : RplcPic temp,1 : RclPic player,height,center-2 : If rand(2)=1 Then : wall-2→wall : XorPic shift2,0,wall : EndIf : getKey()→key : when(key=337,0,1)→d : EndWhile : While not pxlTest(height,center) and key≠264 and d<0 : score+1→score : StoPic temp,0,7 : RplcPic temp,1,8 : RclPic player,height,center-2 : If rand(2)=1 Then : XorPic shift2,0,wall : wall+2→wall : EndIf : getKey()→key : when(key=340,0,-1)→d : EndWhile :EndWhile :Text "Score: "&string(score) :RclGDB graphset :setMode(modeset) :setGraph("Grid",graphopt[1]) :setGraph("Axes",graphopt[2]) :setGraph("Labels",graphopt[3]) :ClrDraw :DispHome :EndPrgm  # An Explanation The general idea of the program is that we store all data about the tunnel directly on the screen. We test for collisions with the pxlTest() command, and use StoPic and RplcPic to scroll. There are, of course, other methods we could have used, such as keeping a list of the wall coordinates. This would have been effective if drawing to the screen was the time-consuming aspect of the program (since only two pixels on each row would need to be changed); however, updating a list turns out to be more time-consuming. Altogether, the method used in this program seems to be the fastest. As a design choice, once a key is pressed, the player drifts in that direction until another key is pressed. This not only makes the game more interesting, but allows for an interesting optimization later on. Now we'll go over the phases of the program in detail. ## Setup This is the beginning of the program, starting from the first line (Local center, … graphset) and ending with the 12th line (when…→height). Here, we prepare the settings that we will need for the program — this is a phase very specific to 68k TI-Basic programming (and would be very different or missing entirely in another language). We will declare all the variables we use as Local, so they are deleted when the program finishes running. Next, we account for mode settings. setMode() changes the general settings, while setGraph() changes the graph-specific settings. We need to save them, too: StoGDB saves the current graph as an image, while the output of setGraph() saves the old settings in the variable graphopt. The next 4 instructions, ClrDraw through PlotsOff, ensure that nothing on the screen interferes with what we draw to it. Finally, we use getConfg() to find out the screen dimensions, to calculate the two parameters we need: center (the center column of the screen) and height (the height at which to draw the player sprite). ## Initialization This phase starts with the 13th line (For i,…,-1) and ends with the 23rd line (0→key). Here, we initialize all the variables, and prepare the screen for the main loop. This is different from the setup phase because it actually involves the logic of our program. The For..EndFor loop draws the initial sides of the tunnel. No matter the calculator model, the tunnel itself stays 35 pixels wide. Then, we initialize the three pictures — the player sprite, and two 'shift' sprites that we'll use later on. Since the sprites are small, it's better to use NewPic to create them, than to keep them outside the program. Finally, we initialize four variables — wall, score, dir, and key. This is a good place to describe the meaning of all the variables we'll need in the main loop: • center and height, as we've said, represent the coordinate of the center column, and the height at which to draw the player. • player, shift1, and shift2 are sprites. • temp is a temporary sprite used to store the entire screen and then scroll it. • wall stores the column coordinate of the left edge of the topmost part of the wall. • score is the score (measured by the number of frames). • key is the key code of the key pressed. • dir represents the direction of motion: 0 for forward, 1 for right, and -1 for left. ## The Main Loop The main loop of this game is the outermost While..EndWhile loop. The idea is that, as long as the game is still going, the program will be going through this loop over and over. In optimizing for speed, this main loop has been split up into three sub-loops: one for drifting forward, one for drifting right, and one for drifting left. Whenever a key is pressed, the inner While loop ends, and the program goes to the While loop that matches the player's current direction. Since the game also needs to be exited whenever 1) a collision occurs or 2) the player presses the ESC key, these two conditions are also added to each loop. You'll notice that the code in each inner loop is mostly similar. In fact, if we were optimizing for size, we could shrink the program significantly by combining these loops into one. However, the division into three loops has a purpose: the parts of the loop that are different would require a complicated conditional statement to combine, which would make going through each loop slower. As it is, the conditional checks only need to be done when the player presses a direction key. Despite their differences, all three loops accomplish the same thing. First, the score is increased by 1 each time. Second, the screen is scrolled: it is stored to the temporary picture 'temp', and then the same picture is recalled a row lower. Of course, this has also shifted the player sprite one row lower, so we need to redraw it where it was before. Also, when we're drifting left or right, the temporary picture is recalled a column right or a column left of where it was, respectively. (A fine point of the program: notice that when drifting left, instead of storing the picture from column 0 and recalling it at column 1, we store it from column 7 and recall it at column 8. This prevents a significant speed hit in this particular loop: recalling such a large picture to a column that's not a multiple of 8 (this is called displaying an unaligned sprite) is much slower) Now, the only thing that remains to be done is to adjust the topmost row, shifting it left or right randomly. When drifting forward, this is simple. The shift1 picture is made up of only two pixels, which are 35 columns away. Using XorPic to display it will change these two pixels, resulting in a shift of 1 pixel (the direction depends on if we're changing the set pixels or the reset pixels near the boundary). We adjust the 'wall' variable accordingly. When drifting left or right, the situation becomes slightly trickier. Say the player is drifting left. Then if we do nothing, the wall gets shifted a pixel right through the scrolling process. To shift the wall left, on the other hand, requires changing two pixels on either side. We accomplish this with the shift2 picture (which is just two copies of shift1). When drifting right, of course, the situation is reversed. ## Closing The closing phase is what happens when the game is over. In this case, this means the player has crashed or pressed the ESC key; either way, this phase is simple. We merely display the score in a text box. It might have been more complicated if we'd included high score functionality. ## Cleanup Only slightly trickier is the cleanup phase (going from RclGDB graphset to the final line). We don't have to worry about cleaning up variables, since they were declared as Local. We do have to take care of the settings: RclGDB restores the graph settings we saved earlier, and setMode() restores the rest. Finally, we should clear the screen. ClrDraw does this, but does not refresh the screen, so if that's all we do, the player will be left on the graph screen and the image of the tunnel will still be there. To prevent this, we use DispHome — this displays the home screen. # Final Optimizations If this game were to be released, some changes would have to be made. Here, we've avoided any optimizations that would impact the readability of the program. Here they are, for completeness: • Replace the arguments of setMode() and setGraph() with their numerical equivalents (which are smaller and foreign-language compatible). • Replace all variables with one-letter variables (which are smaller and slightly faster to access) • Rather than declaring them as Local, accomplish cleanup as follows: 1. Create a new folder using NewFold. 2. Use the one-letter variables as they are needed. 3. Replace ClrDraw at the end with NewProb, this will delete all one-letter variables. 4. End the program by deleting the new folder. However, you might be surprised to find out that the indentations at the beginning of each line don't actually increase program size. The indentation count, for better or for worse, is stored with each new line, no matter if there is an indentation or not. The programs linked from this page are complete (if simple) programs, presented with source code and an explanation. They are meant as a way of putting everything that is on this guide together into an example of what TI-Basic programmers like you can do. For readers who learn better by example than by explanation, these games are also a great way to learn the techniques explained in this guide. These programs have been fully optimized, except where this would interfere with readability. For example, the names of variables could easily be converted to single characters — this was deliberately left undone. The individual pages explain what would be done to finish the job of optimization. Tunnel Racer — a game of reaction in which you race through a twisting tunnel, trying to avoid crashing. RSA Encryption — an implementation of a popular public-key encryption algorithm. Symbolic Division — a function that does symbolic division. Disable On Button [68k OnBlock] — blocks the use of the on button during program execution System variables are special reserved variable names used by some of the commands internally. They exist outside the folder structure that the other variables are located in, so they can be accessed in the same way from any folder. Unlike normal variables, which take between 1 and 10 bytes to reference, system variables always take up 2 bytes, no matter how long the name. # Graph Variables ## Equation Variables The equation variables contain the equations that get graphed for each graphing mode. They include: • y1(x)–y99(x) in function mode • xt1(t)–xt99(t) and yt1(t)–yt99(t) in parametric mode • r1(θ)–r99(θ) in polar mode • u1(n)–u99(n) and ui1–ui99 in sequential mode • z1(x,y)–z99(x,y) in 3D mode • y1'(t)–y99'(t) and yi1–yi99 in differential equation mode ## Cursor Variables The cursor variables include xc, yc, zc, tc, rc, θc and nc. Some of them are updated whenever the crosshair cursor is being moved around on the graph screen, and are especially useful with the Input command. However, the rules that determine which ones get updated are a little tricky: • xc and yc are always updated, regardless of any settings. • The rest get updated depending on graphing mode: zc for 3D mode, tc for parametric mode, rc and θc for polar mode, and nc for sequential mode. • In addition, rc and θc get updated even outside polar graphing mode, if the graph format is set to polar coordinates. ## Window Variables The window variables define the parameters of the graphing window - they are not only used for graphing, but also with point commands such as PtOn. The most basic of them are xmin, xmax, ymin, and ymax: these determine the lower and upper bounds of the window. There are also more advanced settings: • xscl and yscl determine the distance between tick marks on the axes, if the axes are enabled. • Δx and Δy determine the distance between two pixels next to each other. They are calculated automatically from xmin-ymax, but you can set them yourself (xmax and ymax will be adjusted to fit). • xfact and yfact determine the factor by which the window is stretched when you zoom in or zoom out. Some window variables are specific to graphing mode: 1. In function mode: • xres determines the number of pixels between sample points for graphs (a higher value means lower quality). 2. In parametric mode: • tmin and tmax determine the range of the variable t when graphing. • tstep determines the increment of the t variable between two sample points on the graph (a higher value means lower quality). 3. In polar mode: • θmin and θmax determine the range of the variable θ when graphing. • θstep determines the increment of the θ variable between two sample points on the graph (a higher value means lower quality). 4. In sequential mode: • nmin and nmax determine the n values to evaluate at: u(nmin), u(nmin+1), …, u(nmax) will be evaluated. • plotStrt and plotStep determine the n values that actually get graphed: starting at plotStrt, and increasing by plotStep each time. 5. In 3D mode: • zmin and zmax (similarly to xmin and xmax) control the upper and lower bounds of the graphing window, for the z coordinate. • zscl (similarly to xscl) controls the distance between tick marks on the z axis, if the axes are enabled. • zfact (similarly to xfact) controls the factor by which the z-coordinate is stretched when you zoom in or out. • xgrid and ygrid determine the resolution of the wireframe grid. • eyeθ, eyeφ, and eyeψ control the viewing angle (eyeθ is the angle with the x-axis, eyeφ is the angle with the z-axis, and eyeψ is a rotation around the resulting line of sight) • ncontours is the number of contours to graph. 6. In differential equation mode: • t0 determines the t-value for the initial conditions. • tplot and tmax determine range of the variable t when graphing. • tstep determines the increment of the t variable between two sample points on the graph (a higher value means lower quality). • ncurves determines the number of solution curves drawn if you don't give an initial condition. • diftol (with the Runge-Kutta method) and Estep (with the Euler method) determine a step size for calculations. • fldres determines the number of columns for the slope field, if one is drawn. • dtime determines the point in time at which a direction field is drawn (if one is drawn at all). • fldpic is a picture variable that stores the slope field to avoid redrawing it if it's unnecessary. ## Graph Zoom Many of the above window variables have a zoom variable counterpart, prefixed with a z. These are saved by the ZoomSto and ZoomRcl commands. # Statistics Variables ## Regression models These variables are created when you calculate a curve to fit a set of data, using one of these commands: LinReg, MedMed, QuadReg, CubicReg, QuartReg, PowerReg, ExpReg, LnReg, or Logistic. • regeq(x) is the curve that was calculated, as a function of x. • regcoef is a list of the coefficients calculated. • corr is the correlation coefficient (a measure of the direction and goodness of fit) of a linear model. • R2 is the square of corr, but can be calculated for all models. A value close to 1 indicates a good fit; a value close to 0 is poor. • medx1, medx2, medx3, medy1, medy2, and medy3 are calculated by the MedMed method. ## Sample Statistics These variables are calculated by the OneVar and/or TwoVar commands (only those that deal with one variable are calculated by OneVar). •\bar{x}$and$\bar{y}$are the averages of each data set. • Σx and Σy are the sums. • Σx2 and Σy2 are the sums of the squares. • Σxy is the sum of the products of matching pairs of the two data sets. • minX, maxX, minY, and maxY are the minimum and maximum. • Sx and Sy are the sample standard deviations. • σx and σy are the population standard deviations. • nStat is the number of elements in a data set. • medStat, q1, and q3 (for OneVar only) are the median, first quartile, and third quartile. # Other Variables The rest of the variables don't fit into any of the above categories. • c1–c99 are columns in the last data variable shown in the Data/Matrix editor. • errornum contains an error code once an error has occured, for use in Try..Else..EndTry blocks. • eqn and exp are used by the numerical solver (the equation to be solved is stored in eqn, and this is set equal to exp if the = sign was omitted). • ok is set to 1. if a Dialog menu has been exited successfully, and 0. if it was exited with the ESC key. • seed1 and seed2 are the seeds for the random number generator used by rand(). • sysData is the default data variable used by the BldData command. • sysMath stores the result of any graphing calculation (for example, for calculating the derivative at a point on the graph) • tblStart and Δtbl are used to calculate the table input when it is automatic. • tblInput stores the table input when it's not automatic. So far, we can write a calculator program that will make certain computations with numbers or variables and stop — this is just like doing math on the calculator normally. But this is really not that useful! We want the program to be able to ask you a question and give you an answer: to let you "talk" to the program when it's running, so to speak. In programmer language, we call this input and output. Input happens when a program lets the person running it press a key or type something in, so that it can do something with that. Output happens when a program displays results on the screen. Since these are fairly essential ideas, there are a lot of commands associated with them. We'll begin with two: Input and Disp. Unlike storing to variables, these commands can only be used in programs. To type them, open a program to edit. Press PRGM to get the menu of program commands, and the right arrow key, to select I/O (short for Input/Output). The very first option is Input, and the third is Disp. A short synopsis of what they do: # Input :Input var (where var can be replaced by any of the variables we've learned about) will pause the program to display a question mark, and let the calculator user type in a number. Then, the number will be stored to var, and the program will resume. A note on the Input command — to make things more fancy, you can add some text (in quotes as usual) before the variable name. Then, this text will replace the question mark. Input A just displays a generic ? with no help on what it might mean. Input "A=",A will display A= which gives some indication of what to type. # Disp :Disp whatever will display whatever, which can be nearly anything: a number, a variable, a formula involving numbers or variables or both, and even text. A note on the Disp command — to display text, put it in quotes (ALPHA and + make a quote symbol). If you were to just type Disp COOL, the calculator will think you mean the product of C, O, O, and L. By putting it in quotes, Disp "COOL", you tell the calculator that something is text. You can display several things at once, by adding commas: Disp "NUMBER",5 will first display the text NUMBER and then the value 5. # What can we do with this? Text entering tips You can use math symbols to enter fancier characters than just uppercase letters. • [MATH][LEFT][4] (factorial) to type ! • [2nd][ANGLE][2] (minutes) to type ' See this page for a program that will allow you to use lowercase letters. With these tools, we can touch on one of the key uses of programming: simplifying repetitive tasks. Say you have 50 math problems which all look the same: given the sides of a rectangle, find the perimeter and area. Outside a program, you'd have to type out the calculations each time. With a program, you can let the calculator do that for you: :Input "FIRST SIDE?",A :Input "SECOND SIDE?",B :2(A+B)→P :Disp "PERIMETER",P :Disp "AREA",AB  This is our first useful program, so let's go through it line by line: 1. Input "FIRST SIDE?",A will display the text FIRST SIDE? and let the user type in a number. This will be stored to A (the variable we use to represent the first side of the rectangle). 2. Similarly, Input "SECOND SIDE?",B will display SECOND SIDE? and let the user type in a number to store to B, representing the second side of the rectangle. 3. 2(A+B)→P stores the result of 2(A+B) to a new variable, P. 2(A+B) is the formula for the perimeter of a rectangle. 4. Disp "PERIMETER",P displays the text PERIMETER and then the value of P (which will be a number representing the perimeter of the rectangle) 5. Disp "AREA",AB is similar, but does two things at once. After displaying the text AREA, it computes the value AB (the area), and immediately displays it. Of course, we could have handled perimeter the same way we handled area, Disp "PERIMETER",2(A+B). This would have let us combine two lines into one. However, the way the program is now, if the value of the perimeter is ever needed again (should we make the program longer), P will save it for the future as well. ## More on the Subject A wider look at the area of input and output can be found at this page. Command Summary Defines a label for a particular Goto or Menu( to jump to. Command Syntax Lbl name Menu Location While editing a program, press: 1. PRGM to enter the PRGM menu 2. 9 to choose Lbl, or use arrows TI-83/84/+/SE 1 byte The Lbl command is used together with the Goto command to jump (or branch) to another place in a program. When the calculator executes a Goto command, it stores the label name in memory, and then searches from the beginning of the program for the Lbl command with the supplied name. If it finds it, it continues running the program from that point; otherwise, if the label does not exist, it throws a ERR: LABEL error. Label names can be either one or two characters long, and the only characters you're allowed to use are letters (including θ) and numbers 0 to 9; this means 37+37*37=1406 possible combinations. Of course, you should use all of the single character names first, before using the two character names. While you can technically have the same label name multiple times in a program, it is rather pointless since the calculator always goes to the first occurrence of the label. You can position a Lbl command one or more lines before a Goto command to create a kind of loop structure. However, you have to provide the break-out code, since it isn't built-in. An If conditional is easiest, but if there is no code that ends the branching, then program execution will continue indefinitely, until you manually exit it (by pressing the ON key). :Lbl A :... :If <exit condition> :Goto A // this line is skipped  Although the Lbl/Goto loop structure may seem like a good alternative to loops, it should be avoided whenever possible, which is especially important when you are first planning a program. This is because it has several serious drawbacks associated with it: • It is quite slow, and gets slower the further the Lbl is in your program. • It makes reading code (your own, or someone else's) much more confusing. • In most cases, If, For(, While, or Repeat can be used instead, saving space and improving speed. • Using a Goto to exit any block of code requiring an End command causes a memory leak — around 40 bytes of memory will be rendered useless each time you do it until the program finishes running, which will also slow down your program down. They aren't all bad, however, and are actually useful when a loop isn't practical and when something only happens once or twice. Just remember that you should never use Goto to repeat a block of code several times. Use For(, Repeat, or While instead. Labels are also used with the Menu( command. The same considerations apply as with Goto, except that (unless you write a custom menu routine) there's no simple alternative to using labels with Menu(. # Error Conditions • ERR:INVALID is thrown if this statement is used outside a program. • ERR:LABEL is thrown if the corresponding label doesn't exist. # Related Commands  Welcome to the TI-Basic Developer (TI|BD) Starter Kit! This tutorial is designed to help new TI-83 and TI-84 TI-Basic programmers get their feet off the ground. The tutorial is divided into chapters that each have their own focus, and is meant to be read in sequential order. If you have questions or get stuck, leave a post on the forums and somebody will assist you. Happy coding!  1. Getting Started 2. The Basics of TI-Basic 3. Creating Games 4. Advanced Graphics 5. Math Functions 6. Optimization 7. Putting It All Together 8. Miscellaneous A variable is a place where a number can be stored. If you look at the keyboard of your calculator, you'll see a little green letter next to nearly every key. You can type these letters by pressing ALPHA and then pressing the key next to the right letter. Each of the letters A through Z (as well as the funky θ symbol, which is Greek and pronounced "theta") is a variable that can hold a number. If you just type any of these variables on the home screen, and press ENTER, you'll most likely get the value 0 back. That means that the number stored in that variable right now is 0. But you can change this! Right above the ON key is the STO▶ key, which can be used to insert the → arrow. This arrow is called the store command, because it can be used to store a number to a variable. Just type, for example, 5→A, and press ENTER, and the value 5 will be stored in the variable A. Now, if you type A, you should get the number 5 back instead of 0. The number 5 will be saved to the variable A for as long as you need it, until you store something else to A (this is done in the same way). Variables can be used nearly everywhere that numbers can. When using your calculator for math, you might type something like 2+3/8 and the calculator will compute the result. Variables can be used the same way: A+B/C will do the math using the variables A, B, and C, just like it used the numbers 2, 3, and 8 in the previous case. As you've seen, variables are not necessarily linked to programs on the calculator, they work just fine on the home screen. But they are very important in programs, because they are the only kind of memory your calculator has. Imagine you're explaining how to solve a math problem (and writing a program is a lot like explaining a math problem!) You might need to say something like, "Now multiply these two numbers together." Variables, in TI-Basic, and indeed in any programming language, are what you use to say these two numbers. ## More on the Subject A larger look at variables in TI-Basic can be found here. Routine Summary Returns the Rth row of Pascal's triangle Inputs R - The requested row of Pascal's triangle Outputs Ans - Contains the row, as a list Variables Used R, Ans Calculator Compatibility TI-83/84/+/SE Download pascaltriangle.zip :{1 :If R :2^Rbinompdf(R,.5  This routine uses the binompdf( command to generate a row of Pascal's triangle. Each number in Pascal's triangle is gotten by adding the two numbers above it, like such: ....1 1 1 1 2 1 1 3 3 1 1 4 6 4 1  By tradition, the rows are numbered starting with 0, so that 1 is actually the "zeroth" row, while the first row is 1 1. The binompdf( method of calculating rows of Pascal's triangle relies on one of its many properties: if a coin is flipped R times, then the number of heads (or the number of tails) flipped is distributed in the same way as the rows of the pascal's triangle, and the binompdf( command computes precisely such probabilities. We multiply by 2^R to convert the probabilities to whole numbers. Unfortunately, binompdf( doesn't work for the R=0 case, so we make it a special case (if you never need to compute this case, you can omit this, turning the routine into a single statement). Another way to get the number is to use the nCr command. N nCr K returns the Kth element of the Nth row (here, K is also numbered starting from 0). This can be done using the following line of code: :seq(R nCr K,K,0,R  This goes through a line a gets every value of R nCr K and puts all results into a list. This routine is smaller than the one above, but is also slower. # Error Conditions • ERR:DOMAIN is thrown if R is negative, or not a whole number. # Related Routines If one outputs Pascal's triangle to a graph with even numbers as white dots and odd numbers as black dots, the outcome will be Sierpinski's triangle. Another way to generate Sierpinski's triangle is found below: Programming tips Throughout this tutorial, we'll use boxes like this one to give tips that are related to the topic being discussed. These tips teach you quick ways to improve your programs or the way you use them, or warn against common errors. TI-Basic is the built-in programming language on all of TI's graphing calculators. It is an interpreted, which means that it is converted to machine code as it runs. Conversely, a compiled language does not have to be translated before running, so it generally runs much faster. TI-Basic is called such for the similarity between the dialect of the language and various versions of BASIC. TI does not officially call this language TI-Basic, but it is widely accepted across the Internet. Although TI-Basic runs slowly, it is very easy to learn and program, and does not require a computer, unlike assembly. In theory, a person could program assembly directly on the calculator, but then that person would need to know all of the hex codes for every command, and debugging would be nearly impossible. When an error is encountered in TI-Basic, the calculator gives the user the option to go to the problem, which makes debugging much easier. # The Programming Mentality Computers — the calculator is a computer, albeit a small one. Computers execute code one bit at a time, and go through it in the exact way you programmed it. This means you have to make it so that your programs do things in the order you want; the computer can not decide if it makes more sense to do one piece of code before another. Some would argue this the hardest part of programming, and understanding it makes learning a more complicated language like assembly much easier. Programming comes more naturally to some people than others. If you enjoy solving problems and puzzles — you are comfortable with not knowing something, but are dedicated to figuring it out — you probably would be able to be successful at programming. Programming can be a very demanding task, and it requires that you have the right mental aptitude and are persistent. Equally important, though, is your passion for learning and growing. Do you spend hours at a time reading and researching in books and documentation? When you see high-quality programs and games, does that make you want to dissect the program to find out how it works? Passion is often what drives you to keep pushing to the next level, and without it, you will almost be guaranteed to just get tired and give up. Routine Summary Converts a positive integer to a string. Inputs N - the number you want to convert Outputs Str1 - the number N in string form Variables Used X, N, Ans, Str1 Calculator Compatibility TI-83+/84+ series Download numbertostring2.zip :"? :For(X,1,1+log(N :sub("0123456789",ipart(10fpart(N10^(-X)))+1,1)+Ans :End :sub(Ans,1,length(Ans)-1→Str1  Although there is another number to string routine available, it is somewhat difficult to understand, and also uses three additional variables (two lists and a function variable). This routine, on the other hand, is straightforward and doesn't leave any cleanup afterwards. With our number stored in N, we loop through each digit of N and store the numeric character to our string that is at the matching position in our substring. You access the individual digit in the number by using iPart(10fPart(A/10^(X, and then locate where it is in the string "0123456789". The reason you need to add 1 is so that it works with the 0 digit. In order to construct a string with all of the digits of the number, we first create a dummy string. This is what the "? is used for. Each time through the For( loop, we concatenate the string from before (which is still stored in the Ans variable) to the next numeric character that is found in N. Using Ans allows us to not have to use another string variable, since Ans can act like a string and it gets updated accordingly, and Ans is also faster than a string variable. By the time we are done with the For( loop, all of our numeric characters are put together in Ans. However, because we stored a dummy character to the string initially, we now need to remove it, which we do by getting the substring from the first character to the second to last character of the string. Finally, we store the string to a more permanent variable (in this case, Str1) for future use. The way we get the number of digits in a number is by using the 1+int(log( trick. This trick works with any positive whole numbers, and if you add abs( after log(, it will also work with negative numbers. Unfortunately, it does not work with decimals. Also note that we are looping through the digits backwards, and concatenate the previous digit to the next digit. This is done purely for optimization sake. # Reversed version When the string is being concatenated to one that already exists, this code can be optimized by decrementing the For loop rather than incrementing, and appending each character rather than prepending. :[your string here] :For(X,1+int(log(N)),1,-1 :Ans+sub("0123456789",1+int(10fpart(N/10^X)),1 :End :Ans→Str1  # Related Routines This page documents the speed of certain commands in 68k TI-Basic. Now, obviously, the times given here (in seconds) will vary from model to model and even from calculator to calculator (due to battery levels, free memory, and other factors). However, one thing that does not change is the relative speed of the commands. So if you come here to see if If Then..Else..EndIf is faster than when(), the information will be useful on any calculator. Elsewhere in this guide, you might see assertions like "foo() is faster than bar()" without any reason or proof. The information on this page is the reason and proof behind them. # Testing Format For each test done on this page, a variation on the following function was used: timetest(n) :Func :Local t,i :startTmr()→t :For i,1,n <command> :EndFor :approx(1000{checkTmr(t),1}/n) :EndFunc  This function's input, n, is the number of times to loop over the command. The bigger this is, the more accurate the test; however, it will also take longer. The output of this function is a list such as {185 5}. The first of these is the time measurement: how many milliseconds the <command> being measured takes to work. The second of these is an error margin for this measurement. The error occurs because startTmr() and checkTmr() use whole numbers of seconds, so the actual time could be off by just under one second in either direction. In the tables below, such a result will be written as "185±5 milliseconds." For commands that take a very short amount of time, this alternate form may be useful. It takes into account the time that the For..EndFor loop itself takes to run. timetest(n) :Func :Local s,t,i :startTmr()→s :For i,1,n :EndFor :checkTmr(s)→s :startTmr()→t :For i,1,n <command> :EndFor :approx(1000{checkTmr(t)-s,2}/n) :EndFunc  # Contributing your own Tests Feel free to experiment with code timings, and to put your results up on this page. However, be sure to use the same format and method! Also, list the calculator model and the OS version (found in the F1, A:About… menu). Unless stated otherwise, all tests on this page were done with a Voyage 200 calculator and OS version 3.10. That's it for details and explanations. Now come the actual timings! # Loops and Conditionals ## If vs. When The when() command is often a simpler alternative to If..Else..EndIf blocks, when only a single value needs to be stored. It is smaller; this test attempts to ascertain whether it is faster as well. The when() code tested was :when(condition,1,0)  The If code tested was :If condition Then :1 :Else :0 :EndIf  Both tests were done with a true as well as a false condition. Code Time (ms) when(), true condition 8.2±0.05 when(), false condition 8.15±0.05 If..Else..EndIf, true condition 8.5±0.05 If..Else..EndIf, false condition 8.65±0.05 Conclusion: The when() command wins, but not by a lot (though there is a difference that can't be explained by error alone). In addition, the true and false conditions' results are so close, they are probably equal. # Variables ## expr() vs. # Although the expr() and # (indirection) commands do different things, they overlap considerably. If you have a string with a variable name inside, both # and expr() can be used to get you the value of that variable. (In case you're curious, the difference is that #, unlike expr(), can be used to refer to the variable itself, not just its value — but expr() can be used for the value of a whole expression stored to a string). Both commands take 2 bytes when tokenized, so there's no difference in size. The question is — which is faster? Code Time (ms) # 14.35±0.05 expr() 17.05±0.05 Conclusion: it's better to use # than expr() when you can. ## List vs. String vs. Matrix This test attempts to compare the time it takes to access elements of lists, strings, and matrices. Before the test, all three variables were initialized to comparable values: • The list was set to 2048 elements, all of them 0 (as an integer). • The string was set to 2048 spaces. • The matrix was set to 32 rows of 64 columns (a total of 2048 elements), all of them 0 (as an integer). The elements in each case contain one byte of data. However, only the string stores them all with no padding and only a single header; as a result, the list and matrix variables are larger. It's known that while strings are internally stored as an array, lists and matrices are stored as expressions in Reverse Polish Notation. As a result, it's expected that accessing any element of the string will take an equal amount of time; accessing an element of a list or matrix will take longer as the element gets further away from the beginning. Although this wasn't tested, the total size of the variable shouldn't change the access time significantly. List String Matrix Code Time (ms) Code Time (ms) Code Time (ms) list[1] 9.1±0.05 mid(str,1,1) 40.5±0.1 mat[1,1] 9.8±0.05 list[500] 36.8±0.2 mid(str,500,1) 41.8±0.1 mat[1,64] 13.35±0.05 list[1000] 64.5±0.5 mid(str,1000,1) 44.3±0.1 mat[32,1] 115±1 list[2048] 122±1 mid(str,2048,1) 49.6±0.1 mat[32,64] 118±1 Conclusion: Initially, of course, it's faster to access list or matrix elements than string characters. However, the cost rises fairly steeply: for around 600 elements, the string will win. Of course, for storing numerical data, the list will have an additional advantage, but in the long run (say, for 800-1000 elements, depending on the method), the string will be better even for that. You might also consider using several small lists rather than one large one if it's possible. As for the matrix, it's clear that the time cost increases much more quickly going down a column, than across a row. This may be a factor in how you choose to orient your data when it doesn't really matter. You probably won't improve the total time, but the proper orientation will make sure that the time doesn't vary dramatically. Going through the process of debugging your programs may seem like a lot of unnecessary work, but it is better that you find and correct the errors then having the user of your program tell you that your program doesn't work. On this page, we've tried to simplify debugging for you by breaking it down into general steps that you can follow. Just remember to always strive for bug-free programs. # Backup & Document Before debugging, make a backup of your program. This is to ensure that you don't lose your program in its current form. During the debugging process it is easy to mess up your program, overwriting or deleting necessary pieces of code. If you just spent several hours working on your program, you don't want to have all of that work wasted. You should also backup your program before changing anything. This is so you will have a version of your program that you can return to if you mess up your program while doing further debugging. Instead of having to undo any coding mistakes that you made, you can just go back to the last updated version of your program. You also want to document your program and the variables you use. This is important because it makes it easier to come back to the program in the future (if you need to). Documenting a program entails listing what the program does, how it does it, and anything else that might be important. For documenting the variables, you should list out all of the variables, including what they are used for and what values they can have. # Simplify the Code You want to remove any code that is not related to the problem. If you are unsure of what code is related to the problem, look at what its function is. If the code is changing variables or controlling program flow, then it may be important to keep it. If it is just print statements or checking conditionals, you can probably remove it without it affecting the code. Once you have identified the code that contains the error, you will want to create a new program and put the code in it. If the error still exists, you will want to remove parts of the code, repeatedly testing the code afterwards each time. If the error disappears, you know that the last part of the code that you removed is what caused the error. One of the most common problems that programmers make when debugging their code is making lots of changes at once. This is usually not very effective because it can lead to other problems within the code or, if it results in removing some of the errors, you don't know which changes corrected the errors. It also tends to make the debugging process very unorganized because you will have to re-test parts of the code, and sometimes you won't even know which parts need to be re-tested. What you should do instead is fix each problem individually and then test the program. This will take you longer, but your program will have fewer errors and problems. This can further be improved upon by breaking the program up into modules, testing and debugging the individual modules separately from the main program. The advantage of testing the modules by themselves is that it is easier to find errors. Instead of having to look at the whole program, you can look at an isolated part. Once you have removed all of the errors in the module, you don't have to test it again. After going through all of the modules, you then just have to debug the main program that calls the modules. # Analyze The Error When you are trying to fix an error in your program, you will want to gather as much data about it as possible. To do this you should run your program several times, keeping track of when the error occurs, where it is happening, and what type of error it is. Once you think you have a solid grasp of the error, you will want to repeatedly test the code that contains the error. If you can consistently produce the error, you will know that you are on the right track to fixing it. If you can't produce the error, however, that means you need to do more extensive analysis. One of the most effective ways of debugging programs is to walk through the code. This involves sitting down with a printed version of the program, carefully going through its logic. Walking through the code will allow you to see potential solutions to the errors in your program. Once you have a potential solution, you will want to look at how it should work in the code, and then test it to see if it actually works like you believe. The more thorough you are at analyzing the solution, the easier it will be to tell if it will fix the error. Once you know that the solution will fix the problem, you can then apply it to your program. Looking at the variables and their values is essential when you are debugging. You will want to take note of how they gradually change throughout the program. If you know which part of the program contains the error, you can then check the variables that are used within that part. Make sure the variables contain values within their correct limits. If they don't, you need to go to the code before and after the error, and check the value of the variables. Make sure the variables are functioning properly, and that you aren't doing anything to change them. When writing code you will often make assumptions about it. You need to be aware of these assumptions when you are debugging, so you can make sure they are sound. If your program is not functioning properly, you should test all of your assumptions. One of the most common assumptions that programmers make is that the variables they are using are working properly. Most programmers will thoroughly debug their code, but they're not as thorough when debugging variables. Debugging can become very frustrating if you don't thoroughly debug both. # Debugging Tools When you first start debugging your programs, you will want to check to see that the errors you are getting aren't because of a misuse of a command or a misunderstanding of a command's arguments. You should consult the manual to see what the syntax of the command is and how to use it properly. Many errors that you recieve can easily be remedied if you just consult the manual. In fact, if you use the manual when you are programming your program, you can avoid a lot of the typos and superficial errors during debugging. The calculator will detect such syntax errors before it even starts running the program. ## Fixing errors The TI-Basic language has a rather useful feature for debugging programs: when it comes across an error while running your program, it will give you an error menu — telling you what the error is and giving you the option to see where the error is in your code. You will want to take the information that it gives you, and then see if you can figure out why it's producing an error. After the error occurs, you should recall some of your variable's values to see what they are. This might give you an indication of what the error is (if a variable is not in the range it's supposed to be), where in a For loop you are (just recall the variable you used for the loop), and many other helpful hints. To be able to do this, you should avoid using Local variables while still working on a program. ## Debug Mode It's fairly easy to add a debug feature to your program (that you can remove later when you're done working). Add an argument "debug" to the program: :prgmname(debug) :Prgm ...  Throughout code, in questionable parts, add Text commands that only display if 'debug' is true, and show the values of variables you're interested in: If debug Text "Coord: "&string(x)&","&string(y)  When you want the program to run normally, run it as 'prgmname(false)'. Run 'prgmname(true)' instead to enable the debug statements. # Be Prepared For Setbacks After working on debugging a program for a prolonged period of time, with no progress and no new ideas on how to fix the error, you stop being able to effectively debug your program. One of the simplest remedies is to just take a break from debugging and do something else. Take a walk outside around the neighborhood or take a nap. Many times after taking a nap, you will suddenly get the answer to the problem in an epiphany. In addition, it is just a good rule to take frequent breaks from programming so that you don't get burned out so easily. Although it may seem like debugging your program will be a monumental task requiring lots of work, it is essential that you do it. If you are to release your program to the public, you don't want users complaining that it doesn't work correctly or that it contains errors. Another cause of feeling overwhelmed is if you are not very good at debugging. When you are just starting out, you will be able to fix the simple or obvious errors, but you will have a hard time tracking down some of the more complicated errors. The only way to get around this is by repeatedly debugging programs until you have figured out the errors for yourself. The more debugging you do, the better you become at it. It just takes practice. Often when you are debugging a program, and it seems like you just can't find the error in it, you will stop thinking logically and start thinking irrationally. Your only desire is to get the program to work correctly, so you decide that you will do that by whatever means necessary. If you still can't figure out the problem, you might start blaming the calculator or the TI-Basic language. While blaming the calculator or the TI-Basic language will provide you with temporary relief concerning the error in your program, you have to remember that they don't do any of the thinking. They just follow what your program says to do. You are the one that is responsible for the code that you produce. # Get Outside Help If you have tried everything that you know to do and you are still unable to fix the problem, you should now start looking for outside help. You should ask other programmers or go to programming forums. Either one of these should be able to help you with your problem. Asking other programmers for help is a good alternative to getting mad at yourself because you can't figure out the problem. Because you wrote the code, you may make assumptions or have biases when debugging it. You know the code so well that you can't be objective. When another programmer looks at it, though, they don't have any of those hang-ups. In addition, when you're explaining the problem to the other programmer, many times the solution will come to you. Asking the other programmer for help also benefits the other programmer because they improve their confidence debugging programs. If you asked another programmer for help and they could not find and fix the problem, you should then go to programming forums. The advantage of programming forums is that several programmers are working together, building off of each other's ideas. This is the ideal situation because the more people looking at the code, the greater the chance that the problem will be found and fixed. Here are some programming forums that you should go to if you ever need help with a problem: The token 0xEF signifies the beginning of a two-byte token added on the TI-84+(C[S]E). The tokens up to Manual-Fit are for the TI-84+ and the others for the corresponding TI-84+C(S)E. TI-84+(C[S]E) Tokens (0x00 - 0x6F) 0 1 2 3 4 5 6 0 setDate( ClockOn ►n/d◄►Un/d Image1 1 setTime( OpenLib( ►F◄►D BLUE Image2 2 checkTmr( ExecLib remainder( RED Image3 3 setDtFmt( invT( Σ( BLACK Image4 4 setTmFmt( χ²GOF-Test( logBASE( MAGENTA Image5 BackgroundOff 5 timeCnv( LinRegTInt randIntNoRep( GREEN Image6 GraphColor( 6 dayOfWk( Manual-Fit MATHPRINT ORANGE Image7 7 getDtStr ZQuadrant1 CLASSIC BROWN Image8 TextColor( 8 getTmStr( ZFrac1/2 n/d NAVY Image9 Asm84CPrgm 9 getDate ZFrac1/3 Un/d LTBLUE Image0 A getTime ZFrac1/4 AUTO YELLOW Gridline DetectAsymOn B startTmr ZFrac1/5 DEC WHITE BackgroundOn DetectAsymOff C getDtFmt ZFrac1/8 FRAC LTGREY BorderColor D getTmFmt ZFrac1/10 FRAC-APPROX MEDGREY E isClockOn mathprintbox GREY F ClockOff DARKGREY Note: these are tokens for the CE, and from 80h and upper, only OS 5.2 TI-84+(C[S]E) Tokens (0x70 - 0x9F) 7 8 9 0 SEQ(n+1) 1 Quartiles Setting… SEQ(n+2) 2 u(n-2) LEFT 3 tinydotplot v(n-2) CENTER 4 Thin w(n-2) RIGHT 5 Dot-Thin u(n-1) invBinom( 6 v(n-1) Wait 7 w(n-1) toString( 8 u(n) eval 9 PlySmth2 v(n) A Asm84CEPrgm w(n) B u(n+1) C v(n+1) D w(n+1) E pieceWise( F SEQ(n) The token 0x7E signifies the beginning of a two-byte graph format token. By and large, these are the settings from the graph format menu (2nd FORMAT), with some from the mode menu (2nd MODE) thrown in for good measure. All token values here (and elsewhere in this guide) are in hexadecimal. The byte 0x63 signifies the beginning of a two-byte window or finance variable token. All valid such tokens are given below. Note that tokens like u(n-1) are kept for backwards compatibility with the TI-82 only; they will cause a syntax error if entered (which makes it unclear how exactly this exhibits "compatibility," but that's TI's official explanation) All token values here (and elsewhere in this guide) are in hexadecimal. • 63 00 — ZXscl • 63 01 — ZYscl • 63 02 — Xscl • 63 03 — Yscl • 63 04 — u(nMin) • 63 05 — v(nMin) • 63 06 — u(n-1) • 63 07 — v(n-1) • 63 08 — Zu(nMin) • 63 09 — Zv(nMin) • 63 0A — Xmin • 63 0B — Xmax • 63 0C — Ymin • 63 0D — Ymax • 63 0E — Tmin • 63 0F — Tmax • 63 10 — θmin • 63 11 — θmax • 63 12 — ZXmin • 63 13 — ZXmax • 63 14 — ZYmin • 63 15 — ZYmax • 63 16 — Zθmin • 63 17 — Zθmax • 63 18 — ZTmin • 63 19 — ZTmax • 63 1A — TblStart • 63 1B — PlotStart • 63 1C — ZPlotStart • 63 1DnMax • 63 1E — ZnMax • 63 1FnMin • 63 20 — ZnMin • 63 21 — ΔTbl • 63 22 — Tstep • 63 23 — θstep • 63 24 — ZTstep • 63 25 — Zθstep • 63 26 — ΔX • 63 27 — ΔY • 63 28 — XFact • 63 29 — YFact • 63 2A — TblInput • 63 2BN • 63 2C — I% • 63 2D — PV • 63 2E — PMT • 63 2F — FV • 63 30 — P/Y • 63 31 — C/Y • 63 32 — w(nMin) • 63 33 — Zw(nMin) • 63 34 — PlotStep • 63 35 — ZPlotStep • 63 36 — Xres • 63 37 — ZXres The byte 0x62 signifies the beginning of a two-byte statistics variable token (all the valid ones are given below; the remaining ones are unused). The last six tokens on the list (Factor df through Error MS) are for display purposes only, with the ANOVA( command — but if you access them through a hex editor, you can use them to refer to the values of the respective variables. On the other hand, RegEq is only meant to be displayed in the menu, and pastes the contents of the regression equation when selected — it's invalid as a token. All token values here (and elsewhere in this guide) are in hexadecimal. • 62 00 — internal use only • 62 01 — RegEq • 62 02 — n • 62 03$\overline{\textrm{x}}$• 62 04 — Σx • 62 05 — Σx² • 62 06 — Sx • 62 07 — σx • 62 08 — minX • 62 09 — maxX • 62 0A — minY • 62 0B — maxY • 62 0C$\overline{\textrm{y}}$• 62 0D — Σy • 62 0E — Σy² • 62 0F — Sy • 62 10 — σy • 62 11 — Σxy • 62 12 — r • 62 13 — Med • 62 14 — Q1 • 62 15 — Q3 • 62 16 — a • 62 17 — b • 62 18 — c • 62 19 — d • 62 1A — e • 62 1B — x1 • 62 1C — x2 • 62 1D —x3 • 62 1E — y1 • 62 1F — y2 • 62 20 —y3 • 62 21n • 62 22 — p • 62 23 — z • 62 24 — t • 62 25 — χ² • 62 26F • 62 27 — df • 62 28$\hat{\textrm{p}}$• 62 29$\hat{\textrm{p}}_1$• 62 2A$\hat{\textrm{p}}_2$• 62 2B$\overline{\textrm{x}}_1$• 62 2C — Sx1 • 62 2D — n1 • 62 2E$\overline{\textrm{x}}_2\$
• 62 2F — Sx2
• 62 30 — n2
• 62 31 — Sxp
• 62 32 — lower
• 62 33 — upper
• 62 34 — s
• 62 35 — r2
• 62 36 — R2
• 62 37 — Factor df
• 62 38 — Factor SS
• 62 39 — Factor MS
• 62 3A — Error df
• 62 3B — Error SS
• 62 3C — Error MS

The two tables below show all the one-byte tokens by their hexadecimal value - the column is the first hex-digit, and the row is the second, so something in the 2 column and the F row would correspond to the hexadecimal number 0x2F. 2-byte means that this byte signifies the beginning of a 2-byte token (with a link to the appropriate table); unused means that this token isn't used for any actual command.

One-byte tokens by hex code (0x00 - 0x7F)
0 1 2 3 4 5 6 7
0 unused ( randM( 0 and P 2-byte +
1 ►DMS ) mean( 1 A Q 2-byte - (sub.)
2 ►Dec round( solve( 2 B R 2-byte Ans
3 ►Frac pxl-Test( seq( 3 C S 2-byte Fix
4 augment( fnInt( 4 D T Radian Horiz
5 Boxplot rowSwap( nDeriv( 5 E U Degree Full
6 [ row+( unused 6 F V Normal Func
7 ] *row( fMin( 7 G W Sci Param
8 { *row+( fMax( 8 H X Eng Polar
9 } max( (space) 9 I Y Float Seq
A r min( " . J Z = IndpntAuto
B ° R►Pr( , E K θ < IndpntAsk
C ֿ¹ R►Pθ( i or L 2-byte > DependAuto
D ² P►Rx( ! xor M 2-byte DependAsk
E T P►Ry CubicReg : N 2-byte 2-byte
F ³ median( QuartReg newline O prgm mark
One-byte tokens by hex code (0x80 - 0xFF)
8 9 A B C D E F
0 mark ZoomRcl Pt-Change( - (neg.) log( Else Output( ^
1 mark PrintScreen Pxl-On( int( 10^( While ClrHome ×√
2 * ZoomSto Pxl-Off( abs( sin( Repeat Fill( 1-Var Stats
3 / Text( Pxl-Change( det( sinֿ¹( For( SortA( 2-Var Stats
4 Trace nPr Shade( identity( cos( End SortD( LinReg(a+bx)
5 ClrDraw nCr Circle( dim( cosֿ¹( Return DispTable ExpReg
6 ZStandard FnOn Horizontal sum( tan( Lbl Menu( LnReg
7 ZTrig FnOff Tangent( prod( tanֿ¹( Goto Send( PwrReg
8 ZBox StorePic DrawInv not( sinh( Pause Get( Med-Med
9 Zoom In RecallPic DrawF iPart( sinhֿ¹( Stop PlotsOn QuadReg
A Zoom Out StoreGDB 2-byte fPart( cosh( IS>( PlotsOff ClrList
B ZSquare RecallGDB rand 2-byte coshֿ¹( DS<( ClrTable
C ZInteger Line( π √( tanh( Input Plot1( Histogram
D ZPrevious Vertical getKey ³√( tanhֿ¹( Prompt Plot2( xyLine
E ZDecimal Pt-On( ' ln( If Disp Plot3( Scatter
F ZoomStat Pt-Off( ? e^( Then DispGraph TI-84+(C(S)E) LinReg(ax+b)

# Comments

These two-byte tokens are used for the more complicated user-defined variables. All token values here (and elsewhere in this guide) are in hexadecimal.

Note that although these are the only tokens that are accessible from menus, adding any byte after the first (variable-type) byte will give a valid variable name (e.g. the token 5C 0A is a valid matrix, and AA 0A is a valid string). Since this is unintended behavior on the part of the OS developers, these extra tokens will usually appear as a ? symbol. Such tokens can be used if you run out of regular variable names for matrices or strings. It's possible to do the same for pictures, but harder: since StorePic and RecallPic check whether the argument is 0..9, an assembly utility program is required to store and recall them (otherwise, all you need is some assembly program to actually paste the token somewhere).

• 5C 00 — [A]
• 5C 01 — [B]
• 5C 02 — [C]
• 5C 03 — [D]
• 5C 04 — [E]
• 5C 05 — [F]
• 5C 06 — [G]
• 5C 07 — [H]
• 5C 08 — [I]
• 5C 09 — [J]

• 5D 00 — L1
• 5D 01 — L2
• 5D 02 — L3
• 5D 03 — L4
• 5D 04 — L5
• 5D 05 — L6

• 5E 10 — Y1
• 5E 11 — Y2
• 5E 12 — Y3
• 5E 13 — Y4
• 5E 14 — Y5
• 5E 15 — Y6
• 5E 16 — Y7
• 5E 17 — Y8
• 5E 18 — Y9
• 5E 19 — Y0
• 5E 20 — X1T
• 5E 21 — Y1T
• 5E 22 — X2T
• 5E 23 — Y2T
• 5E 24 — X3T
• 5E 25 — Y3T
• 5E 26 — X4T
• 5E 27 — Y4T
• 5E 28 — X5T
• 5E 29 — Y5T
• 5E 2A — X6T
• 5E 2B — Y6T
• 5E 40 — r1
• 5E 41 — r2
• 5E 42 — r3
• 5E 43 — r4
• 5E 44 — r5
• 5E 45 — r6
• 5E 80 — u
• 5E 81 — v
• 5E 82 — w

• 60 00 — Pic1
• 60 01 — Pic2
• 60 02 — Pic3
• 60 03 — Pic4
• 60 04 — Pic5
• 60 05 — Pic6
• 60 06 — Pic7
• 60 07 — Pic8
• 60 08 — Pic9
• 60 09 — Pic0

• 61 00 — GDB1
• 61 01 — GDB2
• 61 02 — GDB3
• 61 03 — GDB4
• 61 04 — GDB5
• 61 05 — GDB6
• 61 06 — GDB7
• 61 07 — GDB8
• 61 08 — GDB9
• 61 09 — GDB0

# First Byte 0xAA (Strings)

• AA 00 — Str1
• AA 01 — Str2
• AA 02 — Str3
• AA 03 — Str4
• AA 04 — Str5
• AA 05 — Str6
• AA 06 — Str7
• AA 07 — Str8
• AA 08 — Str9
• AA 09 — Str0

A string is a collection of letters (usually called characters) in order. They are most commonly used for displaying text, although they can be adapted to any purpose. See the character codes page for a table of the characters that can be part of a string.

To write a string, use quote marks around the characters you want it to contain. For example, "Hello" is a string containing the characters H, e, l, l, and o, in that order. Using the string() command, you can also create a string out of any other variable type.

On the TI-68k calculators, strings have an advantage over lists or matrices - they are a random access structure, which means that accessing the end of the string is just as fast as accessing the end of the string (for a list, on the other hand, the calculator has to go through every previous element of the list to get to an element at the end). Although strings are awkward to access normally, so short strings are at a disadvantage compared to lists, long enough strings will beat out lists and matrices, at least for accessing a specific character.

Except for the constraint of memory, there is no limit to the amount of characters in a string.

# Operations on Strings

There are two special operators that can be used on strings - & (concatenation) and # (indirection). The concatenation operator, &, joins two strings together - "Hello"&" world" returns "Hello world". The indirection operator, #, replaces a string containing the name of a variable by the variable itself - #"f"(x) is the same as f(x) (this can be very powerful, especially for non-algebraic variables such as pictures).

(annoyingly, there is no easy way to type #, on a TI-89. You can select it from the character menu (2nd CHAR, 3, 3) or from the catalog)

The relational operators (=, , >, , <, ) can also be applied to strings. It's easy to see how = and ≠ work: two strings are equal if they are made up of the same characters. For the other relational operators, alphabetical order is used: a string is less than another if it would come before it in a dictionary. But.. not quite — there is a problem with uppercase and lowercase letters. These comparisons are actually done by comparing the character codes of each character in the strings, so all lowercase letters are considered to come after all uppercase letters. That is, "cat"<"dog", as you would expect (because cat comes before dog in the dictionary), but "Dog"<"cat".

The tricky aspect of strings is accessing a character. To do this, you have to use the mid() command: mid(string,start,length) will return length characters from string, starting from start. As a special case, mid(string,n,1) will return the nth character of string. Characters are numbered starting from 1.

# String-Specific Commands

Of course, there are several commands specifically designed to be used with strings (though not as many as we'd like). All of them except shift() and rotate() are found in the string menu (Press 2nd MATH to access the popup math menu, then select D:String).

Before writing any of the code for a program, you should carefully plan out the program. This may seem like an unnecessary step, time that could be better spent, but it will pay major dividends in the end. Planning not only results in better quality programs, but it will also cut down the coding time (since you don't have to waste time rewriting the program) — a win-win situation!

The first thing you want to do when planning a program is to decide what the program will do. Beginner programmers often say that they want to create a cool game, but they don't get much farther than that. For them to have a real chance of creating their program, they need to determine what the objective of the program will be, and then build off of that. For program ideas, see the Project Ideas page.

When coming up with an idea for a program, you should try to be realistic about the limitations of TI-Basic, and what a program can and can not do. For example, a game that needs lots of speed to be worthwhile for the user to play, such as Phoenix or Mario, really isn't very practical in TI-Basic beyond only moving a few things on the screen at any one time.

Once you have determined what the program will do, you need to decide what features the program will have. This can include potential program options, the interface (on the Program I/O screen, or on the graph screen), main menu, an about screen, user help, and any other things you may want. The more thorough you are with planning your program, the easier the coding will be; it is to your benefit to do a good job.

If you can't come up with any ideas for your program or you are unsure of if the ideas that you have come up with make sense, you should get input from the TI community. The three most friendly, active user forums are:

Since these are the kind of people that are going to be using your program when it is finished, you want to ask them to evaluate your program ideas and to offer some constructive criticism. They might also be able to give you some new ideas that you never thought of.

Even if you thoroughly plan a program and get community input, it's simply not possible to think of everything up front. While making changes later on when a program is in heavy development can be a lot more work than making those changes at the beginning, there's nothing wrong with changing or modifying your plans if you believe the program will be better with the change(s).

# Translate It Into Pseudocode

The next step in the process is turning the program plans into pseudocode. Pseudocode involves using English (or whatever language you speak) in place of the TI-Basic code to describe what the program will do to perform the desired functions and tasks. This prevents you from getting caught up in the TI-Basic syntax, allowing you to more clearly focus on the program.

You should first start by looking at the big picture of the program and then break it down into smaller and smaller details. Using an outline as the base, this means you would put the most important things first and then gradually add everything else. This allows you to mentally picture what the program is going to look like and to make sure you don't forget anything.

An important part of creating useful pseudocode is adding comments throughout. It is very easy to get lost in your logic or have problems come up that you don't have any idea on how to resolve. Besides telling you what the code is supposed to do (i.e. making coding easier), it will also force you to slow down and think through the logic of your program. Still, comments are only as good as you make them.

# Use Many Small Programs While Coding

A single large program quickly becomes unwieldy and difficult to manage. While you're still editing the program, it's best to keep it in many small pieces (subprograms). When you're done, you can combine them into one program again.

One of the benefits of this approach is that you can convert pseudocode into a main program almost right away. For example, imagine this pseudocode program:

Setup
Main Menu - user enters difficulty, etc.
Initialize variables
Main Loop:
Player movement
Draw player
Enemy movement
Draw enemy
End Main Loop
If player won the game
Display win message
Otherwise
Display loss message
Cleanup


You could translate this into a basic program almost directly. Here's how we do it (note that we don't write any code yet):

:program()
:Prgm
:setup() © set up settings, variables, etc.
:mainmenu() © user enters difficulty, etc.
:initvars() © initialize variables
:While status=0 © 0=game still going
: moveplr() © move the player
: drawplr() © draw the player
: movenemy() © move the enemy
: drwenemy() © draw the enemy
:EndWhile
:If status=1 Then © 1=won, 2=lost
: wingame() © display Win message
:Else
: losegame() © display Lose message
:EndIf
:cleanup() © clean up settings & variables
:EndPrgm


As another benefit, the tokenization process is cut down significantly - only the programs you changed need to be tokenized again. Also, you can test each sub-program separately.

As you progress in writing the actual code, you create and edit each individual program (for example, you would create and edit mainmenu() and write a menu in that program). Of course, if these sub-programs are big enough, you can split them up into their own sub-sub-programs in the same way.

When all the subprograms are finished, the program will work as it is, in 50 or so pieces (so you can test for bugs and tweak the individual programs). However, if you want to release your program, you probably don't want there to be 50 small programs to send. There are two options for combining the programs into one large program:

• Go through the main program, and replace the subroutines by their code - press 2nd RCL to recall the subroutines into the program, and remove their Prgm and EndPrgm tokens. This is best for subroutines that only get used once.
• At the beginning of the program, add the line Define subprgm()=, and use 2nd RCL again to recall the subprogram after this line. Then, the subprogram will be created when the main program runs, and you can delete it afterwards (or declare is as Local).

Speaking of Local variables: this is a perfectly valid technique for finished programs. However, it can be inconvenient to use when debugging, so it's best to avoid it when you're still writing the program.

When writing a program, you want it to be independent of the user's settings as much as possible - no one should have to set function mode or disable axes to run your program correctly. So your program should change the settings to the necessary ones before running (this is referred to as 'setup'). However, to avoid messing things up for anyone that runs your program, these settings should be restored to what they were before (this is called 'cleanup'). Similarly, you should avoid overwriting any variables.

# Mode Settings

Using setMode(), you can change and restore almost any calculator setting. This only requires two lines of the program. At the beginning of the program, use setMode() to change the settings you want, and store the result to a variable:

:setMode({"Exact/Approx","AUTO","Split Screen","FULL"})→settings


The variable you used will contain the old settings, which you can use to restore them. Add the following line at the end of your program:
:setMode(settings)


setMode() has an alternate, "programmer's syntax" that uses numbers instead of the names of the settings (see the Table of Mode Settings for a list). It's best to use this syntax instead, because it's shorter, and because it ensures compatibility with different language versions:

:setMode({"14","1","8","1"})→settings


Obviously, the settings you'll want to change will depend on what the program does. However, here are some common settings to change:

• Set Graph mode to FUNCTION to use many drawing commands.
• Set Split Screen mode to FULL unless you want the two screens.
• Set Exact/Approx to AUTO and Base to DEC if you're going to be displaying numbers.

# Graph Settings

Almost the same situation occurs with the graph settings, except that the setGraph() command can only change one setting at a time. Set the settings you want at the beginning of the program:

:setGraph("Grid","OFF")→grid
:setGraph("Axes","OFF")→axes
:setGraph("Labels","OFF")→labels


Then restore them at the end:
:setGraph("Grid",grid)
:setGraph("Axes",axes)
:setGraph("Labels",labels)


Like setMode(), setGraph() has a language-compatible syntax, which you should be using both at the beginning and at the end:

:setGraph("3","1")→grid
:setGraph("4","1")→axes
:setGraph("6","1")→labels

<main program code>

:setGraph("3",grid)
:setGraph("4",axes)
:setGraph("6",labels)


With graph settings, you have an alternate method of saving and recalling settings. Use StoGDB to save them at the beginning of the program, and RclGDB to recall them at the end. You'll still need to setGraph() the settings at the beginning, but don't have to save the result.

# Clearing the Screen

In addition to changing the settings, there are several things you need to do to start off with a clear screen.

• If you're using the graph screen:
• Use ClrDraw to clear anything drawn on the screen.
• Use ClrGraph to clear anything the graph commands drew on the screen.
• Use FnOff to disable equations in the Y= editor.
• Use PlotsOff to disable plots.
• If you're using the Program I/O screen:
• Use ClrIO to clear the I/O screen.

As you can see, you might need to use a lot of commands. The good news is that they can all be replaced by the single command NewProb, which does all of the above and more. Unfortunately, NewProb has an unfortunate side effect: it clears the single-letter variables a through z. Since the user might have something important in one of these variables, it's best to stay away from NewProb unless you're working in a separate folder (see the Variables section, below).

At the end of the program, you also want to clear anything you drew to the screen. Here, it's usually enough to use ClrDraw and/or ClrIO. However, due to a quirk in the calculator, if you just run the commands, the calculator won't refresh the screen, so it will look as though you hadn't cleared anything. To avoid this, run DispHome right after these commands.

# Variables

Finally, you want to avoid overwriting the calculator user's variables when your program is running. The simplest way to do this is to use the Local command. Add Local as the first line of your program, and list all the variables you will be using.

There's a drawback to this method: the variables will not be visible to subprograms (which is sometimes a useful thing). Another way to avoid overwriting variables is to work in a separate folder.You might choose always to maintain a separate folder, for example to keep the program's pictures. In this case, you would use setFold() to switch from one folder to another, at the beginning and end of the program:

:setFold(thisgame)→folder

<main program code>

:setFold(#folder)


Alternatively, you might create a temporary folder while the program is running. To avoid collisions make sure the name of the folder has something to do with your program. In fact, you might just use the program name. Keep in mind the name of the folder will be displayed in the corner of the screen.

To do this, you'll need the NewFold and DelFold instructions. At the beginning of the program, save the current folder and create the new one:

:Local folder
:getFold()→folder
:NewFold tempfold


At the end of the program, delete the temporary folder and go back to the original one:
:DelFold tempfold
:setFold(#folder)


Note that the # before the folder is necessary — setFold(folder) will return an error! This because getFold() and setFold() returns a string, not a variable, so you'll need # to turn the string into a variable.

In either case, you can now use global variables (just store to variables each time you need a new one) without worrying about overwriting the user's important variables. At the end of the program, though, you'll probably want to use DelVar to delete all the variables you're not going to save (this is necessary if you're using a temporary folder, otherwise the temporary folder won't get deleted). You can also use NewProb to delete all one-letter variables for you.

# Putting Everything Together

Here is some typical setup and cleanup code:

:mygame()
:Prgm
:Local oldfold
:getFold()→oldfold
:NewFold mygame
:StoGDB graphset
:setMode({"1","1","8","1","14","1","15","1"})→settings
:setGraph("3","1")
:setGraph("4","1")
:setGraph("6","1")
:NewProb

<main program code>

:setMode(settings)
:RclGDB graphset
:ClrDraw
:ClrIO
:DispHome
:DelVar settings,graphset,...
:DelFold mygame
:setFold(#oldfold)
:EndPrgm


Program Summary

A puzzle game where you need to get to the exit as fast as possible.

Program Size

7,500 bytes

Uses Libraries?

No, it's pure TI-Basic

Calculator Compatibility

TI-83/84/+/SE

Author

SiCoDe (Brandon Green)

Download

brickblock.zip

Brick Block was one of the first original puzzle games that appeared in TI-Basic. The premise of the game is that you are a little plus sign (+), and you want to navigate your way to the big plus sign. In order to do that, however, you need to push and pull the white movable blocks that stand in your way. (You can also use the teleport block to teleport yourself to another location on the board.)

The game is one of the first to feature a decent level editor, which allows you to make your own custom levels and then play them in the game. If you just want to play the game, there are twenty built-in levels available — and they are compressed to take up as little space as possible.

When you get tired of playing, you can quit the game, and it will automatically save where you left off for the next time you play. Since the game keeps a highscore based on how efficient you were (calculated by how long it took you to complete and how many moves you needed), you will most likely be playing it again.

.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 2.5 License.