The Or operator allows you to specify alternate conditions which are evaluated independently and if any are true then the entire statement is considered true.
#CASIO CALCULATOR GAMES MANUAL CODE#
Nesting also applies to selection statements, you can nest if or => inside each other as needed.Īs you have just seen, there are times when you will want more than one condition in a selection or loop, you can nest the statements or you can use a logical operator: And, Or, Not.Īnd and Or are operators which can be used in selection statements to specify additional conditions, therefore the code above could be written: The current value in A will be added to the current value of B, that value is then added to the current value of C and then assigned to C.Īs you can see, the second loop executes completely for each iteration (loop) of the first loop. Tells the program that you will be looping until B is equal to 10, adding 1 with each loop. Tells the program that you will be looping until A is equal to 10, adding 1 with each loop. Now we will go through the code and look at what each line does. Here is an example:įor 1->A To 10 //Step can be omitted instead of using Step 1Ĭ_ // the _ represents the output sign, it displays whatever is before it andīy executing this code you will get this output:
![casio calculator games manual casio calculator games manual](https://i.ebayimg.com/images/g/gBMAAOSwKApacojr/s-l300.jpg)
Nesting is when you take one loop and put it inside another. Now that you have a good understanding of both loops and selection statements I will go into the more advanced features of both.įirst off we’ll talk about nesting. In general, the best time to use a if statement is when you have at least to lines of code to be put inside, otherwise use the => arrow. Neat huh? As you can see, the => arrow provides cleaner looking code, and occasionally takes up less space than the if statement. This is the same code as above, except using the => arrow instead of the if statement. The => arrow is also very useful, it is a single line selection statement that takes up less space but can do less than a normal if/else. If you replaced the first line with 0->A then the if statement would evaluate to False, andĪn If statement can contain many different things, and can be many lines long, they are the keystone to making a game, and before going on you should feel comfortable using them. Since A is 1 the statement evaluates to true, therefore They are the If/Else statement and the => arrow.Įlse “BYE” //result if expression is false There are two types of selection statements on the calculator, but one can only be used on models before the AFX series. A selection statement checks an expression, sees if it is True or False, then if True executes the rest of the statement otherwise it skips to below the statement and continues with execution. Selection Statements are used to make programs have differing outcomes, instead to executing the same way every time they are run. LpWhle A<100 //Loops while A is less than 100 Unlike a while loop a Do/LpWhle loop will always execute at least once since it evaluates the expression after the code has been executed. Since the while loop evaluates the expression before executing the code it is possible that if the expression is false before loop begins (ex: 1=2) then the loop will never occure, it will just skip right over the code and continue with the program. While 1=1 //1 always equals 1 so the expression always evaluates to True After the code has been executed it returns to the top, checks the expression, and if it is false jumps out of the loop and continues with executing the program. The While loop checks to see if the expression is true then executes the code. By changing the value of Step you can change how much A is incremented by. Next //Goes back to the start of the loop, adds the step to the variable.Īnything between the For and next statement will be executed until the expression evaluates true (A equals 100). this loop assigns 1 to A then adds 1 to A until it equals 100 Here is an example of a For loop note that it doses not take as many lines. This loop will execute infinitely, Adding 1 to a each time (Actually it will stop when the value of A is greater than 99*10^99 because you will get a mem error).
![casio calculator games manual casio calculator games manual](https://m.media-amazon.com/images/I/61LpbPZg9-L._AC_SY879_.jpg)
![casio calculator games manual casio calculator games manual](https://www.wikihow.com/images/b/bf/Download-Games-Onto-a-Graphing-Calculator-Step-26.jpg)
Here is an example of a Goto/Lbl loop:Ī+1->A //Adds 1 to the variable A and stores new value There are several types of loops in Casio BASIC: Goto/Lbl, Do/lpWhle, For/Next, and While/WhileEnd.