Page 1
Chapter Programming 19-1 Before Programming 19-2 Programming Examples 19-3 Debugging a Program 19-4 Calculating the Number of Bytes Used by a Program 19-5 Secret Function 19-6 Searching for a File 19-7 Searching for Data Inside a Program 19-8 Editing File Names and Program Contents 19-9 Deleting a Program 19-10...
19-1 Before Programming The programming function helps to make complex, often-repeated calculations quick and easy. Commands and calculations are executed sequentially, just like the manual calculation multistatements. Multiple programs can be stored under file names for easy recall and editing. File Name File Name File Name...
19-2 Programming Examples Example 1 To calculate the surface area and volume of three regular octahedrons of the dimensions shown in the table below Store the calculation formula under the file name OCTA. Length of One Side (A) Surface Area (S) Volume (V) 7 cm 10 cm...
Page 4
19 - 2 Programming Examples • The cursor changes form to indicate alpha character input. • The following are the characters you can use in a file name: A through Z, , , spaces, [, ], {, }, ’, ”, ~, 0 through 9, ., +, –, , •...
Page 5
19 - 2 Programming Examples u u u u u To change modes in a program • Pressing 4 (MENU) while the program input screen is on the display causes a mode change menu to appear. You can use this menu to input mode changes into your programs.
Page 6
19 - 2 Programming Examples The following function key menu appears if you press !Z while inputting a program that contains binary, octal, decimal, or hexadecimal calculation. 1 2 3 4 Actual program contents are identical to manual calculations. The following shows how the calculation of the surface area and volume of a regular octahedron would be calculated using a manual calculation.
Page 7
19 - 2 Programming Examples u u u u u To run a program 1. While the program list is on the display, use f and c to highlight the name of the program you want to run. 2. Press 1 (EXE) or w to run the program. Let’s try running the program we input above.
Page 8
19 - 2 Programming Examples • Pressing w while the program’s final result is on the display re-executes the program. P.334 • You can also run a program while in the RUN Mode by inputting: Prog ”<file name>” w. • An error (Go ERROR) occurs if the program specified by Prog ”<file name>” cannot be found.
19-3 Debugging a Program A problem in a program that keeps the program from running correctly is called a “bug,” and the process of eliminating such problems is called “debugging.” Either of the following symptoms indicates that your program contains bugs and that debug- ging is required.
19-4 Calculating the Number of Bytes Used by a Program This unit comes with 26 kbytes of memory. A byte is a unit of memory that can be used for storage of data. There are two types of commands: 1-byte commands and 2-byte commands. •...
To register a password Example To create a program file under the name AREA and protect it with the password CASIO 1. While the program list is on the display, press 3 (NEW) and input the file name of the new program file.
Page 12
To recall a program Example To recall the file named AREA which is protected by the password CASIO 1. In the program list, use f and c to move the highlighting to the name of the program you want to recall.
19-6 Searching for a File You can search for a specific file name using any of the three following methods. • Scroll Search — scroll through the file names in the program list. • File Name Search — input the name of the file. •...
Page 14
19 - 6 Searching for a File u u u u u To find a file using initial character search Example To use initial character search to recall the program named OCTA 1. While the program list is on the display, press 6 (g) 1 (SRC) and input the initial characters of the file you want to find.
19-7 Searching for Data Inside a Program Example To search for the letter “A” inside the program named OCTA 1. Recall the program, press 3 (SRC), and input the data you want to search for. 4 5 6 3(SRC) • You cannot specify the newline symbol (_) or display command (^) for the search data.
19-8 Editing File Names and Program Contents u u u u u To edit a file name Example To change the name of a file from TRIANGLE to ANGLE 1. While the program list is on the display, use f and c to move the highlighting to the file whose name you want to edit and then press 6 (g) 2 (REN).
Page 17
19 - 8 Editing File Names and Program Contents Example 2 To use the OCTA program to create a program that calculates the surface area and volume of regular tetrahedrons when the length of one side is known Use TETRA as the file name. Length of One Side (A) Surface Area (S) Volume (V)
Page 18
19 - 8 Editing File Names and Program Contents 3 4 5 6 2. Edit the program contents. 2(EDIT) eeeeDD cd![bc Let’s try running the program. Length of One Side (A) Surface Area (S) Volume (V) 7 cm 84.87048957 cm 40.42293766 cm 10 cm 173.2050808 cm...
Page 19
19 - 8 Editing File Names and Program Contents...
19-9 Deleting a Program There are two different ways to delete a file name and its program. • Specific program delete • All program delete u u u u u To delete a specific program 1. While the program list is on the display, use f and c to move the highlighting to the name of the program you want to delete.
19-10 Useful Program Commands In addition to calculation commands, this calculator also includes a variety of rela- tional and jump commands that can be used to create programs that make repeat calculations quick and easy. Program Menu Press ! W to display the program menu. 1 2 3 4 5 6 1 (COM) ..
Page 23
19 - 10 Useful Program Commands Clear Command Menu (CLR) While the program menu is on the display, press 6 (g) 1 (CLR) to display the clear command menu. 6(g)1(CLR) 1 2 3 4 5 6 1 (Text) ..ClrText command 2 (Grph) ..
Page 24
19 - 10 Useful Program Commands Pressing 5 (R•Tbl) while the display command menu is on the display causes the recursion calculation and recursion formula graph command menu to appear. 5(R•Tbl) 1 2 3 4 5 6 1 (Tabl) ..DispR-Tbl command 2 (Web) ..
19-11 Command Reference k k k k k Command Index Break ..................343 ClrGraph ................347 ClrList ..................347 ClrText ................... 347 DispF-Tbl, DispR-Tbl ............. 347 Do~LpWhile................342 DrawDyna ................348 DrawFTG-Con, DrawFTG-Plt ..........348 DrawGraph ................348 DrawR-Con, DrawR-Plt ............348 DrawR -Con, DrawR -Plt .............
Page 26
19 - 11 Command Reference The following are conventions that are used in this section when describing the vari- ous commands. Boldface Text ..... Actual commands and other items that always must be in- put are shown in boldface. {Curly Brackets} ..Curly brackets are used to enclose a number of items, one of which must be selected when using a command.
Page 27
19 - 11 Command Reference 3. You can also use a carriage return indicated by _ in place of the multi-statement command. _ (Carriage Return) Function: Connects two statements for sequential execution without stopping. Description: 1. Operation of the carriage return is identical to that of the multi-statement com- mand.
Page 28
19 - 11 Command Reference Description: This command is almost identical to If~Then. The only difference is that the IfEnd- statement is always executed, regardless of whether the If-condition is true (non- zero) or false (0). Example: If A = 0 _ Then ”A = 0”...
Page 29
19 - 11 Command Reference Example: Lbl 1:? If A > 0 And A < 10 _ Then ”GOOD”_ Else Goto 1_ IfEnd The above program displays the message “GOOD” whenever a value that is greater than zero and less than 10 is input. Any other value prompts for input again. For~To~Next Function: This command repeats everything between the For-statement and the Next-statement.
Page 30
19 - 11 Command Reference Syntax: For <starting value> <control variable name> To <ending value> Step <step value> Next Parameters: • control variable name: A to Z • starting value: value or expression that produces a value (i.e. sin , A, etc.) •...
Page 31
19 - 11 Command Reference Syntax: While <expression> ~ WhileEnd Parameters: expression Description: 1. This command repeats the commands contained in the loop as long as its condi- tion is true (non-zero). When the condition becomes false (0), execution pro- ceeds from the statement following the WhileEnd-statement.
Page 32
19 - 11 Command Reference 3. A subroutine can be used in multiple locations in the same main routine, or it can be called up by any number of main routines. Main Routine Subroutines Prog ”D” Prog ”C” Prog ”E” Prog ”I”...
Page 33
19 - 11 Command Reference Example: For 2 I To 10_ If I = 5_ Then ”STOP” : Stop_ IfEnd_ Next This program counts from 2 to 10. When the count reaches 5, however, it terminates execution and displays the message “STOP.” k k k k k Jump Commands (JUMP) Function: This command is a count jump that decrements the value of a control variable by 1, and then jumps if the current value of the variable is zero.
Page 34
19 - 11 Command Reference 3. This command can be used in combination with conditional jumps and count jumps. 4. If there is no Lbl-statement whose value matches that specified by the Goto- statement, an error (Go ERROR) occurs. Example: ? A : ? B : Lbl 1 : X + B ^...
Page 35
19 - 11 Command Reference Description: 1. The conditional jump compares the contents of two variables or the results of two expressions, and a decision is made whether or not to execute the jump based on the results of the comparison. 2.
Page 36
19 - 11 Command Reference Description: 1. These commands generate numeric tables during program execution in accord- ance with conditions defined within the program. 2. DispF-Tbl generates a function table, while DispR-Tbl generates a recursion ta- ble. DrawDyna Function: This command executes a Dynamic Graph draw operation. Syntax: DrawDyna_ Description: This command performs a Dynamic Graph draw operation during program execution in accordance with the drawing conditions defined within the...
Page 37
19 - 11 Command Reference 2. DrawR-Con produces a connect type graph, while DrawR-Plt produces a plot type graph. DrawR -Con, DrawR -Plt Function: These commands graph recursion expressions, with ) as the ver- tical axis and as the horizontal axis. Syntax: DrawR -Con_ DrawR -Plt_...
Page 38
19 - 11 Command Reference k k k k k Input/Output Commands (I/O) Getkey Function: This command returns the code that corresponds to the last key pressed. Syntax: Getkey_ Description: 1. This command returns the code that corresponds to the last key pressed. 2.
Page 39
(1, 7) (21, 7) Example: Cls_ Locate 7, 1, ”CASIO FX” This program displays the text “CASIO FX” in the center of the screen. • In some cases, the ClrText command should be executed before running the above program. Receive ( Function: This command receives data from an external device.
Page 40
19 - 11 Command Reference k k k k k Conditional Jump Relational Operators (REL) G G G G G , >, <, , Function: These relational operators are used in combination with the conditional jump command. Syntax: <left side> <relational operator> <right side> <statement>...
19-12 Text Display You can include text in a program by simply enclosing it between double quotation marks. Such text appears on the display during program execution, which means you can add labels to input prompts and results. Program Display ”X =”...
19-13 Using Calculator Functions in Programs k k k k k Using Matrix Row Operations in a Program These commands let you manipulate the rows of a matrix in a program. P.92 • For this type of program, be sure to use the MAT Mode to input the matrix, and then switch to the PRGM Mode to input the program.
Page 43
19 - 13 Using Calculator Functions in Programs u u u u u To calculate a scalar product and add the results to another row ` ` Row+) Example 3 To calculate the scalar product of Row 2 of the matrix in Example 1, multiplying by 4, and add the result to row 3 The following is the syntax to use for this program.
Page 44
19 - 13 Using Calculator Functions in Programs G SelOn 1_ 4411J DrawGraph !W622 Executing this program produces the result shown here. k k k k k Using Dynamic Graph Functions in a Program P.208 Using Dynamic Graph functions in a program makes it possible to perform repeat Dynamic Graph operations.
Page 45
19 - 13 Using Calculator Functions in Programs k k k k k Using Table & Graph Functions in a Program P.236 Table & Graph functions in a program can generate numeric tables and perform graphing operations. The following shows various types of syntax you need to use when programming with Table &...
Page 46
19 - 13 Using Calculator Functions in Programs k k k k k Using Recursion Table & Graph Functions in a Program P.250 Incorporating Recursion Table & Graph functions in a program lets you generate numeric tables and perform graphing operations. The following shows various types of syntax you need to use when programming with Recursion Table &...
Page 47
19 - 13 Using Calculator Functions in Programs Executing this program produces the results shown here. Numeric Table Recursion graph k k k k k Using List Sort Functions in a Program P.265 These functions let you sort the data in lists into ascending or descending order. •...
Page 48
19 - 13 Using Calculator Functions in Programs • The following is a typical graph condition specification for a scatter diagram or line graph. S-Gph1 DrawOn, Scatter, List1, List2, 1, Square_ In the case of an line graph, replace “Scatter” in the above specification with “...
Page 49
19 - 13 Using Calculator Functions in Programs k k k k k Performing Statistical Calculations • Single-variable statistical calculation 1-Variable List1, List2 Frequency data (Frequency) -axis data (XList) 4161 • Paired-variable statistical calculation 2-Variable List1, List2, List3 Frequency data (Frequency) -axis data (YList) -axis data (XList) •...