There are different forms of getting user input. One can set up the menu( command to have the user choose an option, you can use loops with getKey to have a user move something or make a choice, or you can use the Input and Prompt commands to get data. Getting user input using Input and Prompt would be fairly useless without being able to compare what it is the user input to what value you need it to be. First, we will gather input and redisplay it, and then we shall show you how to "branch" your answers depending on the input recieved.
The simplest form of getting user input is by using the Input command. This command, when used without any arguements, will place a cursor on the graphscreen, and once the user has pressed [ENTER], stores the values of X- and Y-axis from the graphscreen to the X and Y variables. Something that can be useful, and will be covered more in another lesson.
The primary use of Input is to get a value from the user, and store it into a variable, this includes normal variables, strings, lists, Y= variables, and matrices.
Here is some sample code on how to use Input in it's many forms:
:Input "A",A :Input "Str1",Str1 :Input "L1",L1 :Input :Output(1,1,"A: :Output(1,6,A :Output(2,1,"Str1: :Output(2,6,Str1 :Output(3,1,"L1: :Output(3,6,L1 :Output(4,1,"X: :Output(4,6,X :Output(5,1,"Y: :Output(5,6,Y
Here is a screenshot of the above code in action:
The other common way to get information from a user is by using Prompt. Prompt will allow a programmer to gather input for more variables with one command, instead of having an individual Input command for each variable.
Here is a screenshot using Prompt:
As stated above, there are other forms of getting input from a user, but we will get to them in due time. Now, on to Boolean logic!
Boolean Logic is basically comparing values to see if it returns a true or false, and then executing a command, or series of commands based on the result. Commands for working with boolean logic are If, Then, Else, End, IS>( and DS<(. These commands are easy to use incorrectly, so please read through this information carefully and understand it fully before continuing on to any of the other lessons.
Your basic boolean logic in TI-BASIC can be seen in this screenshot:
What you are seeing is the calculator returning "1" for "True", and "0" for "False". Well, how is this helpful, and how does this relate to any of the commands above?? It is simple. What you are seeing is the actual comparing taking place. The If command tells the calculator that: "Hey, we have a single command to execute!" Now before going too far into this, maybe we should take a look at the different formats of If, and some of the commands that go with it (and where they are found).
There are also 6 relational operators that you need to use to do Boolean Logic. They are =, ≠, >, <, <=, >=. These can be found in the TEST menu by pressing 2nd and MATH. When using =, ≠, >, <, <=, >=, you can only compare real numbers, expressions and lists. You can also use them to test the elements of a list and a matrix, but to compare matrix to matrix, they must be the same dimensions, and you can only use = and ≠.
If: This command tells the calculator to check for boolean logic, and to execute a command. Then: Attached to an If command, tells the calculator there is more than one command to execute. Else: Attached to an If:Then line, tells the calculator to go to the next set of commands if the first boolean set was false. End: Attach to the End of an If:Then statement, including Else commands. and: Used with an If statement to check if two or more variables are true at the same time. or: Used with an If statement to check if at least one variable is true when more than one variable is used with an If command. xor: Exlusive or; used to test two variables, to check if at least one equals 0, if both either equal or dont equal 0, will return a 0. not(: Command that checks if a variable equals 0, returns 0 if the value does not equal 0, returns 1 if value does equal 0.