General | ||||
Description | Before | After | Affect | |
---|---|---|---|---|
You can remove closing parentheses, braces, and quotes at the end of a line of code. These things are unnecessary in most cases. The one rare instance where you would want to keep the closing parentheses is when you are dealing with order of operations. | Output(3,2,"Hello") | Output(3,2,"Hello World | Size | |
You can also remove closing parentheses, braces, brackets, and quotes that are before a store command. | "Hello"→Str1 | "Hello→Str1 | Size | |
Rearrange the group of expressions with the most closing parentheses, braces, brackets, and quotes so that they are at the end of the line. | If 5/(A+B)=2 | If 2=5/(A+B | Size | |
Putting multiple commands on the same line (separating each command with a colon) can hinder readability and it can prevent you from taking off the closing quotes. However, there is no difference in size between using a newline or colon, and it can often save lines of code (making scrolling through code easier). | If B=3:Then Disp A:2→C End |
If B=3 Then Disp A 2→C End |
Neither | |
Keep your label and list names as short as possible. You ideally want them to be one character in length. | Lbl AA LHIGH |
Lbl A LH |
Size | |
When displaying text, always look for words that can be replaced with the respective command. The commands are much smaller than writing out the word. | "Return→Str1 | "Return→Str1 | Size | |
You can change all of your text to uppercase. Making your text look nice comes with a price. Lowercase letters are two bytes each instead of one byte like uppercase letters. This can really be costly if your program has a lot of text in it. | Disp "Hello | Disp "HELLO | Size | |
You can often shorten text by removing or rewording words. | Output(3,2,"Too Low | Output(3,2,"Higher | Size | |
Displaying Text | ||||
Description | Before | After | Affect | |
If you have a string of numbers that you are displaying, you don't need to put quotes around the numbers. You should only use quotes if you want to keep any leading zeros. | Disp "2345 | Disp 2345 | Size | |
Use the Disp command instead of the Output command when displaying text on the first line of the homescreen. You can just add spaces to the text to move it to the correct location. | Output(1,2,"Hello | Disp " Hello | Size | |
(For loop optimization) When displaying the same text or variable on three or more lines, use a For loop. A For loop can also be used when the display is changing by a constant increment. |
Output(3,3,1 Output(4,3,2 Output(5,3,3 |
For(X,3,5 Output(X,3,X-2 End |
Size | |
When the text in an Output command is more than sixteen characters, it will wrap around to the next line. When you have two or more Output commands that display text on different lines, you can sometimes put the text together and add blank spaces between it to make it go to the next line in the desired location. | Output(1,6,"Hello World Output(2,2,"Version 1.0 |
Output(1,6,"Hello World Version 1.0 | Size | |
Using the Disp command, you can display text and variables at the same time by putting a comma between each one. Because this can hinder readability, this should only be done when just displaying variables. | Disp A Disp B |
Disp A,B | Size | |
When you have a list of Disp commands that you pause, you can take the text or variable from the last Disp command and place it after the Pause command as its optional argument, allowing you to remove the last Disp command. | Disp "A= Disp A Pause |
Disp "A= Pause A |
Size | |
(String optimization) You can often remove Disp commands by building a string of text (putting the addition operator between each part of the text) and then displaying the text with one Disp command. This can be useful when you have two conditionals that are opposites that display text. |
If A≥10 Disp "Hello If A<10 Disp "Goodbye |
"Hello→Str1 If A<10 "Goodbye→Str1 Disp Str1 |
Size | |
(Conditional optimization) When you have two or more Disp statements inside an If-Then conditional, you should combine the Disp statements so you can change the If-Then conditional to an If conditional. This also works with the Text statements. |
If A>B Then Disp "A is greater Disp "than B End |
If A>B Disp "A is greater","than B |
Size | |
Storing Variables | ||||
Description | Before | After | Affect | |
Although it is common to initialize variables for planned use, you should avoid initializing variables that you don't need or that are initialized further down in the program. The reason is because storing to variables really slows a program down (especially inside loops) and there is no point in initializing a variable twice. | 2→A If B Then 2→A Else -2→A End |
If B Then 2→A Else -2→A End |
Speed | |
When a number is used many times in a program, you should store it to a variable and then just call the variable instead of writing it out every time. This also applies to text that should be put in a string. | Disp "Hello Disp "Hello Disp "Hello |
"Hello→Str1 Disp Str1,Str1,Str1 |
Size | |
You can also put common variables or expressions in a string variable, and then use the expr command to reference them. This can be used in conjunction with other variable commands. This also gives you more variables to use. | C+2->C Disp 5int(B/7 Disp 5int(B/7 |
C+2->C "5int(B/7->Str1 Disp expr(Str1 Disp expr(Str1 |
Neither | |
You should reuse variables that have no specific function or that don't need to be saved. | For(X,1,100 End For(Y,1,50 End |
For(X,1,100 End For(X,1,50 End |
Size | |
When storing the same large number in two or more variables, you should store the large number in the first variable and then store the first variable into the rest of the variables. | 7112→A 7112→B 7112→C |
7112→A A→B A→C |
Size | |
When calculating several repetitive trigonometric or other math functions in a program, it is sometimes faster to just store the values in a list and recall the values when needed. | For(A,0,10 Text(6A+1,1,10cos(A) End |
For(A,0,10 10cos(A→L(A End For(A,0,10 Text(6A+1,1,L1(A End |
Speed | |
Deleting Variables | ||||
Description | Before | After | Affect | |
Instead of setting variables to zero (to delete them), use the DelVar command. DelVar works with all of the variables, and the calculator automatically sets the variable to zero the next time it's used. | 0→A | DelVar A | Neither | |
The DelVar command doesn't need a line break or colon following the variable name. This allows you to make chains of variables. | DelVar A DelVar B |
DelVar ADelVar B | Size | |
Besides making chains of variables, the DelVar command also allows you to take the command from the next line and put it immediately after the last DelVar command. | DelVar A Disp "Hello |
DelVar ADisp "Hello | Size | |
Even though the ClrList command exists for clearing lists, DelVar should be used instead. | ClrList L1 | DelVar L1 | Size | |
User Input | ||||
Description | Before | After | Affect | |
The Input command has an optional display message argument that can be either text or a string. This display message can be used to tell the user what type of value to enter or to show what the variable is for. The Input command should be used instead of using a Disp command in conjunction with the Prompt command. | Disp "Guess Prompt A |
Input "Guess?",A | Size | |
If you have two Input commands that have display messages that are positioned between a conditional, you can often remove one of the Input commands and then use the sub command to display the appropriate display message. This allows you to get rid of the conditional. You can also take out the common part of the display message and add it to the substring part of the display message. | If A=1 Then Input "Take candy?",Str1 Else Input "Give candy?",Str1 End |
Input sub("GiveTake",1+4(A=1),4)+" candy?",Str1 | Size/Speed | |
The Prompt command can be used with more than one variable. If you have a list of prompt commands, you should put all of the variables on the first Prompt command, separating each variable with a comma. This allows you to get rid of the rest of the Prompt commands. | Prompt A Prompt B Prompt C |
Prompt A,B,C | Size | |
The Prompt command should be used instead of the Input command when you have the display message show what the variable being stored to is. And if there are multiple Input commands, you can reduce them to just one Prompt command. | Input "A=?",A Input "B=?",B Input "C=?",C |
Prompt A,B,C | Size | |
When doing calculations and user input, you should move the calculations before the user input. The delay before the user input is not important because people simply can't type fast enough to notice it. | Input "NAME:",Str1 3B/7→L1(1 2A+5B->C |
3B/7→L1(1 2A+5B->C Input "NAME:",Str1 |
Speed | |
Exiting Programs | ||||
Description | Before | After | Affect | |
Although the Return and Stop commands can both be used for exiting programs, Return should be used instead of Stop. While Return stops only the current program and allows the parent program to continue running, Stop causes all of the programs to stop and then returns the user to the homescreen (unless called from an Assembly program). | ClrHome Disp "Hello Stop |
ClrHome Disp "Hello Return |
Neither | |
You don't have to use Return or Stop if you can organize the program so that it just naturally quits. If the calculator reaches the end of a program, it will automatically stop executing. | ClrHome Disp "Hello Return |
ClrHome Disp "Hello |
Size | |
When you have a display command that displays text as the last line of the program, you can remove the command and just put the text. This text will be displayed instead of the "Done" message that is normally displayed after a program finishes executing. | ClrHome Disp "Hello |
ClrHome:"Hello | Size | |
Even though you don't display any text as the last command, you may still want to get rid of the "Done" message. You can do this by putting a single double-quote as the last line of the program. | ClrHome | ClrHome:" | Neither | |
If you modify the Ans variable on the last line of the program, Ans's new value will be displayed instead of the "Done" message. | ClrHome For(A,1,5 B+A→B End |
ClrHome For(A,1,5 B+A→B End B |
Neither | |
Boolean Logic, Operators, And Functions | ||||
Description | Before | After | Affect | |
Because the calculator treats every nonzero value as true and zero as false, you don't need to compare if a variable's value is nonzero. Instead, you can just put the variable by itself. | If C≠0 | If C | Size | |
When making expressions that combine the and and or operators where the and operator comes first, you don't need to include parentheses around the and operator. The and operator has a higher precedence than or, so it is evaluated first. This can become complicated with complex expressions, so you might want to leave some of the parentheses for clarity. | If (A=1 and B=2) or (A=2 and B=1) | If A=1 and B=2 or A=2 and B=1 | Size | |
If you are comparing two unary expressions (expressions with no comparison operator) with the and operator, you don't need the and operator. For and to be true, both values must be nonzero. So, multiplying them will produce the same effect because if either one of the values is zero, the product of both values will also be zero. | If A and B | If AB | Size | |
If you are comparing two unary expressions with the or operator, you can usually replace the or operator with the addition operator. For or to be true, one or both values must be nonzero. So, adding the values will produce the same effect. The one place where this does not work is when B is equal to negative A. | If A or B | If A+B | Neither | |
The most unused logical operator is xor (exclusive or). The xor operator is useful when comparing two expressions and checking if one but not both are true. In fact, xor is specifically designed for this purpose. | If A=2 and B≠2 or A≠2 and B=2 | If A=2 xor B=2 | Speed/Size | |
Instead of comparing a variable to zero, use the not logical operator. Because not returns the opposite value of the variable, true will become false and false will become true. | While A=0 | While not(A | Size | |
Min is useful when you are comparing one variable or value to several other variables to see if they are all equal to the variable or value. To use min you just create an expression with the min function and put the common variable or value inside it followed by an equal sign and a left curly brace. You then list out the variables that you are comparing the variable or value to, separating each one with a comma. | If A=10 and B=10 and C=10 | If min(10={A,B,C | Size | |
Max is useful when you are comparing one variable or value to several other variables to see if at least one is equal to the variable or value. You do the same thing as the min function, just replacing min with max. | If A=10 or B=10 or C=10 | If max(10={A,B,C | Size | |
You can put a comparison operator inside the min or max functions to compare when several values or variables are equal to one variable and several values or variables are equal to another variable. This works especially well with two or more variables. | If A=X and B=U or A=Y and B=V | If max(A={X,Y} and B={U,V | Size | |
Abs is useful when you are comparing a variable to two even or odd values using the or operator. You subtract the larger value from the smaller value, divide the result by two, and then put it on the left side of the equal sign. Next, you subtract the larger value by the result on the left side of the equal sign, and then take the variable being tested and subtract it by that value. You then put the abs function around the result and place the expression on the right side of the equal sign. | If A=45 or A=105 | If 30=abs(A-75 | Size | |
Many times a compound expression can be shortened by combining expressions that have the same meaning or replacing expressions that can be written another way. Think about what the expression means and then think about how to make a shorter equivalent expression. There are many ways of writing an expression, so there are usually ways to rewrite it. | If A>B or A<B | If A≠B | Speed/Size | |
If you have the not operator around an expression, you can usually change the logical operator to the math opposite. This allows you to remove the not operator. | If not(B=C and A=D | If B≠C or A≠D | Size | |
DeMorgan's Law can be used for expressions in which the not operator is around two separate unary expressions joined by the and or or operators. It allows you to remove the second not operator and then change the and to or and vice versa. | If not(A) and not(B | If not(A or B | Size | |
Conditionals | ||||
Description | Before | After | Affect | |
Use If conditionals when you only want to execute the one command on the next line and speed isn't important. | If A=1 Then C+2→C End |
If A=1 C+2→C |
Size | |
Because If-Then conditionals are 2.5x faster than If conditionals you may want to change an If conditional into an If-Then conditional. | If A=1 C+2→C |
If A=1 Then C+2→C End |
Speed | |
Because If conditionals are generally slow, you should replace them with Boolean conditionals if you are just changing a variable. You take the variable and add or subtract the expression, multiplying it by the value that you are adding to the variable. Using Boolean conditionals can sometimes be slower than If conditionals because it may unnecessarily store zero into the variable if the expression is false. | If A=3 B+2→B |
B+2(A=3→B | Speed/Size | |
You don't need to put the value in front of the expression when it is one. | B+1(A=2→B | B+(A=2→B | Size | |
You can take Boolean conditionals a step further by combining multiple If conditionals that deal with the same variable and put them into one Boolean conditional. | If A=3 B+5→B If A=6 B-3→B |
B+5(A=3)-3(A=6→B | Speed/Size | |
If you are adding and subtracting the same value from the variable in the Boolean conditional, you can factor the common value from each expression. This works best when you are adding and subtracting a big number. | B+11(A=1)-11(A=2→B | B+11((A=1)-(A=2→B | Size | |
If a Boolean test is frequently done, the test should be stored to a variable. | B+(A=3→B C-(A=1)+(A=3→C |
A=3→D B+D→B C-(A=1)+D→C |
Size | |
You can sometimes reorder a list of If conditionals so that the last possible outcome doesn't even need an If conditional. This mainly works when the program is going to do a certain action and there are no other alternative actions that can occur. | If not(A Goto A If A=1 Goto B If A=2 Goto C |
If A=2 Goto C If A Goto B Goto A |
Size | |
If-Then-End conditionals should be used when you want to execute multiple commands. | If A=1 C+1→C If A=1 D+1→D |
If A=1 Then C+1→C D+1→D End |
Speed/Size | |
If you have two or more If conditionals that have a common expression, you should take the common expression out and make it into an If-Then-End conditional and nest the If conditionals inside it. | If A=1 and B=1 C+2→C If A=1 and B=2 D+1→D |
If A=1 Then If B=1 C+2→C If B=2 D+1→D End |
Speed/Size | |
If you are displaying lots of text based on If conditionals, you should put the text together and then just use the sub command to get the appropriate part of the text. This will display the text if none of the conditions are true, so this may not always be desired. | If A=3 Disp "Hello If A=4 Disp "World |
Disp sub("HelloWorld",1+5(A=4),5 | Size | |
The If-Then-Else-End conditionals should be used if you want to execute multiple commands when an expression is true or false. Instead of putting two If-Then-End conditionals that have math opposite expressions, If-Then-Else-End conditionals are faster because you don't need to do two checks; only one of the conditionals can be true at one time. | If B Then "Hello→Str1 End If not(B Then "Goodbye→Str1 End |
If B Then "Hello→Str1 Else "Goodbye→Str1 End |
Speed/Size | |
When using an If-Then-Else conditional and only one command is executed if the expression is true or false, use an If conditional between the two commands instead. You might also have to change the order of the commands, depending upon the commands. | If B Then "Hello→Str1 Else "Goodbye→Str1 End |
"Goodbye→Str1 If B "Hello→Str1 |
Size | |
When a line is either drawn or erased depending on a condition, you can put that condition as the optional fifth argument for the Line command. | If B:Then Line(1,2,3,4 Else Line(1,2,3,4,0 End |
Line(1,2,3,4,B | Speed/Size | |
When you have a If-Then or If-Then-Else conditional that has a Goto command as one of the nested commands, you can sometimes remove the conditional and replace it with multiple If conditionals. Doing this prevents a memory leak from happening. | If A Then Disp "Hello Goto A Else Disp "Goodbye B+2→B End |
If A Disp "Hello If A Goto A Disp "Goodbye B+2→B |
Speed/Size | |
Loops -- For, Repeat, While, And Goto/Lbl | ||||
Description | Before | After | Affect | |
When using loops you want to make them as compact as possible. This starts with moving invariant code outside the loops. You only want loops to contain expressions whose values change within the loops. If something only happens once, it should be outside the loop. | For(X,1,5 5→Y Disp X End |
5→Y For(X,1,5 Disp X End |
Speed | |
You also want to minimize the calculations inside loops. This not only includes cutting down on the number of storages, but how often variables are used and what they are used for. This can increase the size, however. | For(X,1,10 A+length(Str1→A End |
length(Str1→B For(X,1,10 A+B→A End |
Speed | |
Another way to minimize calculations inside loops is to use constant increments. This makes the loop faster, but it also makes it larger. | For(X,0,10 Disp 10X End |
For(X,0,100,10 Disp X End |
Speed | |
You should combine two or more loops that are in close proximity if they use the same number of iterations and don't affect each other. Combining loops may take some ingenuity. | For(X,1,10 B+X→B End For(Y,1,10 A+A/Y→A End |
For(X,1,10 B+X→B A+A/X→A End |
Speed/Size | |
Loop unrolling reduces the number of times you check the condition in a loop, with two or more of the same statements being executed for each iteration. If the loop is small enough, you can even unroll the whole loop. This will usually increase the size but also make it faster. | 5→dim(L1 For(X,1,5 2A→L1(X End |
5→dim(L1 2A→L1(1 2A→L1(2 2A→L1(3 2A→L1(4 2A→L1(5 |
Speed | |
For loops are best used when you know how many times the loop will be executed. Because the fourth argument is optional (one is the default), you should always try to leave it off. | For(X,1,8,1 End |
For(X,1,8 End |
Size | |
You can sometimes rewrite For loops and the commands inside them so you can remove the fourth argument. | For(X,8,0,-1 Disp X End |
For(X,0,8 Disp 8-X End |
Size | |
If you have an If-Then-End conditional around the outside of a For loop, you should combine it with the For loop using Boolean logic. | If A>10 Then For(X,0,100 End End |
For(X,0,100(A>10 End |
Size | |
One of the common uses of For loops is to slow programs down. Instead of For loops, you should use rand(# or If max(rand(#. Both of these create lists of random numbers, with a larger number meaning a larger delay. The second one preserves the Ans variable, though. | For(X,1,75 End |
rand(25 | Size | |
Repeat loops will loop until the expression is true and While loops will loop while the expression is true. Repeat loops are tested at the end of the loop which means they will be executed at least once. This allows you to not always have to set the variables in the expressions, which is the case with While loops. If the expression in a While loop is false before it is tested, the loop will be skipped over. This is sometimes desired if the expression fits that format. | DelVar A While not(A getKey→A End |
Repeat A getKey→A End |
Size | |
If you need a loop that loops forever (an infinite loop) use Repeat 0 or While 1 instead of Goto/Lbl. | Lbl A Disp "Hello Goto A |
Repeat 0 Disp "Hello End |
Size | |
Goto/Lbl loops should be used sparingly. When Goto is encountered, it notes the label and proceeds to search for it from top to bottom in the code. This can really be slow if the label is deep within the program. It also has the tendency to make your code harder to follow and maintain. And, if you use a Goto to exit a loop or a conditional that uses an End, it can lead to memory leaks (causing your program to crash). | Repeat 0 getKey→B If B Goto A End Lbl A |
Repeat B getKey→B End |
Speed/Size | |
When all a For loop does is store expressions to a list, you can replace it with a sequence command. The sequence command can also be used with other variables. | 5→dim(L1 For(X,1,5 2A→L1(X End |
seq(2A,X,1,5→L1 | Speed/Size | |
Math Operations, Keys, Rules, And Identities | ||||
Description | Before | After | Affect | |
Multiplication signs are unnecessary and should be removed because the calculator does implicit multiplication. You should remember that implicit multiplication doesn't bind tighter than regular multiplication. | 5*A→B | 5A→B | Size | |
You don't need to put parentheses around a single variable or number by itself when doing multiplication or division. | 3/(A) | 3/A | Size | |
Multiplication and division have the same importance based on the order of operations (the rules that determine what order things are evaluated in), so they will be evaluated from left to right if both appear in an expression. If multiplication appears before division, you can remove the parentheses around an expression. | A+(BA)/5→C | A+BA/5→C | Size | |
When adding a negative number to a positive number, switch the two numbers around and change the addition to subtraction. This allows you to get rid of the negative sign. | -A+B→C | B-A→C | Size | |
You can often times rewrite math expressions using the built-in keys and characters. When you have a number that has two or more zeros, it may be smaller to write it using the small-E exponent character. This character will multiply the number on its left (1 if no number is given) times 10 to the number given on the right. | 50000 | 5E4 | Size | |
If you want to use a variable to set the exponent of a number, you would have to use 10^X because the calculator doesn't allow EX. This can be replaced with the 10^( key. This also applies to the e^( key, the 2 key, and the 3 character. | 10^A+e^2-5^2+9^3 | 10^(A)-52+93+e^(2 | Size | |
If you have a fraction that has one as the numerator, you can replace it with multiplying the denominator by the -1 key. | 1/16 | 16-1 | Size | |
When you have a fraction that has an expression in the numerator that has parentheses around it and a variable in the denominator, you can sometimes eliminate the fraction by multiplying the variable by the -1 key and multiplying it by the expression from the numerator. | If (A+B)/C | If C-1(A+B | Size | |
If you raise a variable or value to some fractional power with one in the numerator, you can just take the denominator of the fractional power and then multiply it by the xroot character and the variable or value. | A^(1/B | Bxrt(A | Size | |
Always do all the operations you can ahead of time. This eliminates some of the operations that the calculator has to do. | 33+A(8/2→B | 27+4A→B | Speed/Size | |
Write and calculate expressions in one step instead of several steps. | 2BC→D 3A→E D+E→F |
2BC+3A→F | Speed/Size | |
One of the basic math rules is that multiplying one times any variable is equal to the variable. So, you don't need to put the one in front of the variable. | 1A+3→B | A+3→B | Size | |
When adding two variables of the same type together, you should add up the number of times the variable appears and multiply that value by the variable. | A+3A→B | 4A→B | Speed/Size | |
Rewriting division with multiplication is useful when multiplying is smaller. You take the denominator and then change it to the equivalent for multiplication. | (X+1)/10 | .1(X+1 | Speed/Size | |
The distributive identity should be used when you have three or more variables that share a common number or variable. You take that common number or variable out and distribute it to all of the variables. | CA+CB+C2→D | C(A+B+C→D | Size | |
The multiplicative inverse identity is used when you have an expression where the same variable or value is in the numerator and denominator. You can remove the variable or value because it is canceled out. | 2A/(2BA | 1/B | Speed/Size | |
When you have a fraction that has a fraction as its denominator, you can sometimes use the division inverse identity. If the numerator of the first fraction is one, you can flip the second fraction causing the first fraction to disappear. | 1/(4/A | A/4 | Speed/Size | |
Putting Ans Into Practice | ||||
Description | Before | After | Affect | |
The Ans variable (last answer) is a temporary variable that can hold any variable. Ans is changed when there is an expression or variable storage or when pausing with the Pause command. It is mostly useful when you are just manipulating one variable. To use Ans just put an expression on a line by itself; it will automatically be stored to Ans. You can then change the expressions on the next line where the variable was called and put Ans there instead. | getKey→A B+(A=26)-(A=24→B |
getKey B+(Ans=26)-(Ans=24→B |
Speed | |
If you have more than one line that calls the variable, you should just keep the variable. However, for the first line that calls the variable you should change the variable to Ans. | getKey→A B+(A=26)-(A=24→B C+(A=34)-(A=25→C |
getKey→A B+(Ans=26)-(Ans=24→B C+(A=34)-(A=25→C |
Speed | |
If you store the same value to two or more variables one after the other, use Ans for each one after the first variable. | 500→A A→B A→C |
500→A Ans→B Ans→C |
Speed | |
When there is a common expression that is on multiple lines, it is sometimes smaller to put the expression on its own line and then change the expression on the other lines to Ans. | 30+5A→B Disp 25A Disp 30+5A |
30+5A→B Disp 25A Disp Ans |
Size | |
When you use the same text many times in close proximity, you should put that text on its own line and replace it with Ans wherever it occurs. | Disp "Hello Disp "Hello Disp "Hello |
"Hello Disp Ans,Ans,Ans |
Size | |
For complex calculations, there are often multiple parts that are the same. You should take out the most common part and put it on its own line. If there are several common parts, you should take out the part that will result in the greatest size reduction. You then replace that part, wherever it occurs, with Ans. | 2A/(BC)+(BC)2→A | BC 2A/Ans+Ans2→A |
Size | |
When you have an If conditional and speed is a priority, it is faster to put the condition on its own line and replace the condition in the conditional with Ans. | If A and not(B | A and not(B If Ans |
Speed | |
When dealing with text there are often situations where the same text is repeated multiple times. Rather than writing out the long string of text, it is sometimes possible to rewrite it using Ans. Put the common part of the text on its own line and on the next line concatenate (add together) with Ans however many times is needed to make the string. | " →Str1 //20 spaces | " //5 spaces Ans+Ans+Ans+Ans→Str1 |
Size | |
If you use the sub command to get the appropriate part of some text based on certain conditions, you can sometimes get rid of the sub command and just use Ans. You would put each piece of text on its own line, and then put the condition before it. | Input sub("GiveTake",1+4(A=1),4)+" candy?",Str1 | "Give If A=1:"Take Input Ans+" candy?", Str1 |
Size | |
Because Repeat loops are executed at least once, you can sometimes put Ans in the condition instead of the variable. | Repeat A getKey→A End |
Repeat Ans getKey→A End |
Speed | |
When the condition in a Repeat loop has a common part that is repeated multiple times, you should put the common part at the end of the loop and replace the common part in the condition with Ans. | Repeat A=2 and B=1 or A=2 and B=3 getKey A+(Ans=26)-(Ans=24→A End |
Repeat Ans and B=1 or Ans and B=3 getKey A+(Ans=26)-(Ans=24→A A=2 End |
Size | |
Many times in If-Then-Else conditionals the same expression or string of text appears in both the true and false parts. You should put this expression or string of text before the If-Then-Else conditional and then replace it in the conditional with Ans. | If B Then Disp "Hello 2Bnot(A→C Else Disp "Hello 3→D End |
"Hello If B Then Disp Ans 2Bnot(A→C Else Disp Ans 3→D End |
Size | |
When you have two or more strings of text that share a common part, you should take that common part out. You then can replace it with Ans and concatenate Ans to the strings. | Disp "Hello World Disp "Goodbye World |
"World Disp "Hello "+Ans Disp "Goodbye "+Ans |
Size | |
When you have two If conditionals that have math opposite conditions and they display text, it is sometimes possible to remove one of the conditionals and use Ans. Take the text from the first condition and put it on its own line. Then put the second conditional and the text on the next line. You then put the display Ans on the last line. | If A≤B Disp "Higher If A>B Disp "Lower |
"High If A>B "Low Disp Ans+"er |
Size | |
Graphscreen | ||||
Description | Before | After | Affect | |
Although the screen is 95 pixels wide and 63 pixels tall, the bottom row and far right column of pixels are unusable. So, most people set the graphscreen dimensions to 94 and 62. This itself should be replaced with storing 1 into deltaX and deltaY. | 0→Xmin:94→Xmax 0→Ymin:62→Ymax |
0→Xmin:1→ΔX 0→Ymin:1→ΔY |
Size | |
(Covered) The Text command can display both variables and text at the same time on the same line. This allows you to sometimes remove multiple Text commands and just use the first one. |
Text(5,5,A Text(5,9,"/ Text(5,13,B |
Text(5,5,A,"/",B | Size | |
(Covered) The Pxl-On command is faster than Pt-On, and it should be used whenever possible. Pt-On is also affected by the screen dimensions, while Pxl-On is not. |
Pt-On(5,5 | Pxl-On(5,5 | Speed | |
(Covered) The Line command has an optional fifth argument that controls whether the line will be drawn (the argument should be one) or erased (the argument should be zero). The default is one, and it should be left off when possible. |
Line(5,5,10,5,1 | Line(5,5,10,5 | Size | |
(For loop optimization) When turning multiple pixels in a straight line on or off, use a For loop instead of using the individual pixel commands. |
Pxl-On(5,5 Pxl-On(5,6 Pxl-On(5,7 Pxl-On(5,8 |
For(X,5,8 Pxl-On(5,X End |
Size | |
(Obsolete) When you change the same pixels from on to off or vice versa, use the pixel change command instead of the individual pixel commands. |
For(X,5,8 Pxl-On(5,X End For(X,5,8 Pxl-Off(5,X End |
For(X,5,8 Pxl-Change(5,X End |
Size | |
(Covered) When you have multiple pixels in a straight line that you turn on or off, you can sometimes replace the Pxl-On commands with Line commands. |
Pxl-On(5,5 Pxl-On(5,6 Pxl-On(5,7 Pxl-On(5,8 |
Line(5,5,5,8 | Size | |
(Covered) The Pt-On and Pt-Off commands have an optional third argument that should never be used when one is desired because one is the default. |
Pt-On(5,5,1 | Pt-On(5,5 | Size | |
(Obsolete) The optional third argument for Pt-On and Pt-Off should be used when you want to turn on or off a 3x3 outline of a box (the argument should be two) or a 3x3 cross (the argument should be three). This can be used instead of the individual commands. |
Pt-On(A,B-1 Pt-On(A,B Pt-On(A,B+1 Pt-On(A-1,B Pt-On(A+1,B |
Pt-On(A,B,3 | Size | |
(Covered) When wanting to clear large spaces of the graph screen, you should use the Line or Text commands instead of the pixel commands, when possible. Both of these commands are faster than the pixel commands. |
Pxl-Off(5,5 Pxl-Off(5,6 Pxl-Off(5,7 Pxl-Off(5,8 |
Line(5,5,5,8,0 | Speed |