Output Commands: Output commands make the calculator display something on the screen. Now that you understand how to create a new program, make one called "HELLO". Yes, that's right. One of those cheesy Hello World programs. Type in the following code:
:Disp "Hello World"
That's pretty simple, huh? Exit the editor and run your first program. The calculator should display "Hello World" without the quotes, then display "Done" to tell you that it has finished executing the program. What you just did was told the calculator to display the string "Hello World". A string may consist of letters, numbers, and/or practically any other character that you can type. Strings must be surrounded by quotation marks. If you just want to display numbers, you don't have to use quotes. If you want to display "Hello World" over two lines, erase what you just entered and type this in:
:Disp "Hello","World"
This displays "Hello" on the first unused line, and "World" on the second. Now for another output command: Outpt(. That's not a typo, it's supposed to be "Outpt(". This command is more powerful than Disp. It allows you to tell the calculator where on the screen to display your string. Go back into the "HELLO" program and clear the line that you typed in a minute ago. In its place, enter:
:Outpt(1,6,"Hello World"
Run the program. Notice where it displays "Hello World". It starts on the 1st row, 6th column. The first number (1) is the row to start the string on, and the second number (6) is the column to begin at. That means that typing
:Outpt(3,2,"Goodbye"
would place the word "Goodbye" beginning at row 3, column 2. There's on more cool thing that you can do with the Outpt( command. Change your program so that it looks like this:
:Outpt(3,2,"Good"+"bye"+"!"
When you run this, you'll discover that the "+" sign actually attached the three strings together. this seems pointless now, but you'll see a better use of this in the sample program later. Play with Disp and Outpt(; familiarize yourself with them. Our last output command is "Text(". It works almost exactly like the Outpt( command, but on the graph screen. Once again, clear out the code in "HELLO" and replace it with
:Text(0,45,"Hello World"
This will display "Hello World" at PIXEL row 0 and PIXEL column 45 on the graph screen. Always remember that there are 127 pixels across (Numbered 0 through 126) and pixels 63 down (Numbered 0 through 62). Run the program, and familiarize yourself with the Text( command.
The ClLCD command isn't really an output command, but it's close enough. It clears the home screen. Here's an example:
:Disp "Noooooooooo!"
:ClLCD
:Disp "Hey!"
This displays "Noooooooooo!", clears the screen, then displays "Hey!". A similar command, called "ClDrw", clears the graph screen. Try this code:
:Text(1,1,"I am about to be cleared."
:ClDrw
:Text(1,1,"Hey, looks like it works!"
The program will display "I am about to be cleared.", clear the graph screen, then display "Hey, looks like it works!".
Input Commands: Input commands allow the user to type something in. The most common of these is the "Input" command. Create a new program called "PROMPTER". Type this in:
:Input "Enter Your Age: ",A
:ClLCD
:Disp "This is your age:",A
Now run the program. The calculator displays "Enter Your Age: ", then allows the user to type in a number. The number is stored to the variable A. The program then clears the screen and displays the contents of variable A, which is your age as you typed it in. The "Input" command has another use.
:Input
In the above code, the program is paused, the graph screen is displayed, and the user is put in control of a cursor that can be moved around the screen. When [ENTER] is pushed, the program resumes. The x and y coordinates of the cursor when [ENTER] was pressed are stored to the variables X and Y. Who knows, this may be useful for something... It's like a cheap BASIC mouse with [ENTER] for a button ;)
Our next input command is InpSt, the input string command. Whereas Input only allows the user to enter a number, InpSt allows strings. Clear out everything and enter the following code instead:
:InpSt "Enter Your Name: ",N
:ClLCD
:Disp "So, your name is",N
This is exactly like the previous example, but it allows letters too. If you had entered anything besides numbers in the previous example you would have received an error.
Our final input command is the Prompt command. This may be the simplest of the three. Clear out all the code in your "PROMPTER" program and enter this:
:Prompt A
:ClLCD
:Disp A
This makes the calculator display "A=?", allows the user to enter a number, and stores that number to A. The calculator then clears the screen and displays whatever number the user entered. The Prompt command is especially useful for getting numbers from the user to stick into an equation, as it can input more than one number with a single command like this:
:Prompt A,B,C,X,Y
This short line of code displays "A=?" and allows the user to type in a number to be stored to variable A. It then displays "B=?", and stores the value that the user entered to variable B. It does the same thing for C, X, and Y. As you can see, this code takes up much less space than if Input commands had been used. Experiment with all of the commands on this page before moving on.
From now on, when you see a link like the one below, click it to see the code for examples of real program that demonstrate the use of the commands that you have learned so far.
Practice Program: "Hello" - Practice the skills you learned in this chapter
Got all this covered? Excellent, now on to Chapter 3: Math and Variables.
Click to Return to This Tutorial's Home Page