| Ti-83 Basic | |||
| The Basics 1.1: Getting Started 1.2: The "Disp" Command 1.3: The "Input" Command 1.4: Strings 1.5: If-Then Statements 1.6: "For" Loops 1.7: "While" Loops 1.8: The "Getkey" Command Creating Menus 2.1: Lbl and Goto Commands 2.2: The "Menu" Command Graphics 3.1: Setting up for Drawing 3.2: Graphing 3.3: Graph-Coordinates Drawing 3.4: Screen-Coordinates Drawing 3.5: Pictures 3.6: "Input" Revisited 3.6: Advanced Menus 3.8: Dynamic Menus 3.9: Dialog Boxes Miscellaneous 4.1: Memory Management 4.2: Creating Lists and Saved Games 4.3: Using with MirageOS 4.4: Tips and Hints | "While" Loops While loops are commands that aren't used as much as other commands, but are an essential part of programming when you need them. While loops, like their names, repeat themselves as long as the variable equals or does not equal something. Here's an example: :0->D :While D=0 :Input "D?",D :Disp D :End This program will keep asking what D is until you enter some number besides 0. How do these help? Well, here we will try writing a program that will show you.
:15->A :ClrHome :0->G :While G=0 :Input "What is the number?",N :If N=A :Then :Disp "You got it!" :1->G :End :If N>A :Disp "Too High" :If N (is greater than) A :Disp "Too Low" :End That was it. You might ask "What the heck is going on with the variable G and the While loop? It's what makes the program ask you again if you get it wrong. G is whether you have guessed the number or not. If you haven't, it's 0, and if you have, it's 1. While you haven't guessed the number (G=0), then ask for the number and tell whether it's right or wrong. After you guess it, G is set equal to 1, and since G no longer equals 0, it ends the while loop, thus ending the program. You will be faced with problems like these all the time when programming. It takes a good knowledge of the commands you have avalible to you and a knowledge of how to use theses commands. Don't be afraid to experiment! That's the best way to learn the feel for the programming language. If you did good on this program, you'll do well on others. If you didn't play around with the language a bit to get a feel for the commands and how they work. One last thing before you move on. What if you want the number to change every time? There's a function that makes a random number. Press [MATH],[Right Arrow],[Right Arrow],[Right Arrow],[5] to get the randInt( function. In the parenthesis, type a range (for this program, 1 to 100 is good). In the guess program, in place of 15->A, Put the function randInt(1,100)->A. | ||
![]() The text in this tutorial is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License. | |||

