Casio CFX-9850G PLUS Programming Manual

Casio CFX-9850G PLUS Programming Manual

20. programming
Hide thumbs Also See for CFX-9850G PLUS:

Advertisement

Chapter
Programming
20-1
Before Programming
20-2
Programming Examples
20-3
Debugging a Program
20-4
Calculating the Number of Bytes Used by a Program
20-5
Secret Function
20-6
Searching for a File
20-7
Searching for Data Inside a Program
20-8
Editing File Names and Program Contents
20-9
Deleting a Program
20-10
Useful Program Commands
20-11
Command Reference
20-12
Text Display
20-13
Using Calculator Functions in Programs
20

Advertisement

Table of Contents
loading

Summary of Contents for Casio CFX-9850G PLUS

  • Page 1 Chapter Programming 20-1 Before Programming 20-2 Programming Examples 20-3 Debugging a Program 20-4 Calculating the Number of Bytes Used by a Program 20-5 Secret Function 20-6 Searching for a File 20-7 Searching for Data Inside a Program 20-8 Editing File Names and Program Contents 20-9 Deleting a Program 20-10...
  • Page 2: Before Programming

    20-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...
  • Page 3: Programming Examples

    20-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 20 - 2 Programming Examples • Use 1 (RUN) to input a program for general calculations (a program to be executed in the COMP Mode). For programs that involve number system specifications, use 2 (BASE). Note that programs input after pressing 2 (BASE) are indicated by to the right of the file name.
  • Page 5 20- 2 Programming Examples • Pressing 6 (SYBL) displays a menu of symbols ( ’, ”, ~, * , /, # ) that can be input into a program. • Pressing ! Z displays a menu of commands that can be used to change set up screen settings inside a program.
  • Page 6 20- 2 Programming Examples The following shows examples of how to actually use the ? and ^ commands. !W4(?)aaA6(g)5(:) c*!9d*aAx 6(g)5(^) !9c/d*aAMd !Q or JJ 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.
  • Page 7 20- 2 Programming Examples · · · · · · · · · · · · • Pressing w while the program’s final result is on the display re-executes the program. P.378 • You can also run a program while in the RUN Mode by inputting: Prog ”<file name>”...
  • Page 8: Debugging A Program

    20-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 debugging is required.
  • Page 9: Calculating The Number Of Bytes Used By A Program

    20-4 Calculating the Number of Bytes Used by a Program There are two types of commands: 1-byte* commands and 2-byte* commands. * A byte is a unit of memory that can be used for storage of data. • Examples of 1-byte commands: sin, cos, tan, log, (, ), A, B, C, 1, 2, etc. •...
  • Page 10: Secret Function

    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 11 20- 5 Secret Function 2. Press 2 (EDIT). 3. Input the password and press w to recall the program. • The message “Mismatch” appears if you input the wrong password.
  • Page 12: Searching For A File

    20-6 Searching for a File There are three different methods for searching for a specific file name. u u u u u To find a file using scroll search Example To use scroll search to recall the program named OCTA 1.
  • Page 13 20- 6 Searching for a File 2. Press w to search. • All files whose file names start with the characters you input are recalled. • If there is no program whose file name starts with the characters you input, the message “Not Found”...
  • Page 14: Searching For Data Inside A Program

    20-7 Searching for Data Inside a Program Example To search for the letter “A” inside the program named OCTA 1. Recall the program. 2. Press 3 (SRC) and input the data you want to search for. 3(SRC) • You cannot specify the newline symbol (_) or display command (^) for the search data.
  • Page 15: Editing File Names And Program Contents

    20-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 highlight- ing to the file whose name you want to edit and then press 6 (g) 2 (REN).
  • Page 16 20 - 8 Editing File Names and Program Contents Use TETRA as the file name. Length of One Side (A) Surface Area (S) Volume (V) 7 cm 10 cm 15 cm The following are the formulas used for calculating surface area S and volume V of a regular tetrahedron for which the length of one side is known.
  • Page 17 20- 8 Editing File Names and Program Contents 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 117.8511302 cm 15 cm 389.7114317 cm 397.7475644 cm 1 (EXE) or w (Value of A)
  • Page 18: Deleting A Program

    20-9 Deleting a Program There are two methods for deletion of a file name and its program. 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 highlight- ing to the name of the program you want to delete.
  • Page 19: Useful Program Commands

    20-10 Useful Program Commands In addition to calculation commands, this calculator also includes a variety of relational 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. •...
  • Page 20 20- 10 Useful Program Commands k k k k k DISP (display command menu) Selecting {DISP} from the program menu displays the following function menu items. u {Stat}/{Grph}/{Dyna} ... {statistical graph}/{graph}/{Dynamic Graph} draw u {F-Tbl} ... {Table & Graph command menu} The following are the items that appear in the above menu.
  • Page 21: Command Reference

    20-11 Command Reference k k k k k Command Index Break ..................378 ClrGraph ................382 ClrList ..................382 ClrText ................... 382 DispF-Tbl, DispR-Tbl ............. 383 Do~LpWhile ................377 DrawDyna ................383 DrawFTG-Con, DrawFTG-Plt ..........383 DrawGraph ................383 DrawR-Con, DrawR-Plt ............384 DrawRΣ-Con, DrawRΣ-Plt .............
  • Page 22 20- 11 Command Reference The following are conventions that are used in this section when describing the various commands. Boldface Text ..... Actual commands and other items that always must be input 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 23 20- 11 Command Reference : (Multi-statement Command) Function: Connects two statements for sequential execution without stopping. Description: 1. Unlike the output command (^), statements connected with the multi- statement command are executed non-stop. 2. The multi-statement command can be used to link two calculation expressions or two commands.
  • Page 24 20- 11 Command Reference If~Then~IfEnd Function: The Then-statement is executed only when the If-condition is true (non- zero). The IfEnd-statement is always executed: after the Then-statement is executed or directly after the If-condition when the If-condition is false (0). Syntax: <condition>...
  • Page 25 20- 11 Command Reference If~Then~Else~IfEnd Function: The Then-statement is executed only when the If-condition is true (non-zero). The Else-statement is executed when the If-condition is false (0). The IfEnd-statement is always executed following either the Then-statement or Else-statement. Syntax: <condition> Then <statement>...
  • Page 26 20- 11 Command Reference Parameters: • control variable name: A to Z • starting value: value or expression that produces a value (i.e. sin , A, etc.) • ending value: value or expression that produces a value (i.e. sin , A, etc.) Description: 1.
  • Page 27 20- 11 Command Reference 3. Making the starting value less than the ending value and specifying a positive step value causes the control variable to be incremented with each execution. Making the starting value greater than the ending value and specifying a negative step value causes the control variable to be decremented with each execution.
  • Page 28 20- 11 Command Reference 2. Since the condition comes after the While-statement, the condition is tested (checked) before the commands inside the loop are executed. Example: 10 → A_ While A > 0_ A – 1 → A_ ”GOOD”_ WhileEnd k k k k k Program Control Commands (CTL) Break Function: This command breaks execution of a loop and continues from the next...
  • Page 29 20- 11 Command Reference Main Routine Subroutines Prog ”D” Prog ”C” Prog ”E” Prog ”I” Prog ”J” Level 1 Level 2 Level 3 Level 4 4. Calling up a subroutine causes it to be executed from the beginning. After execution of the subroutine is complete, execution returns to the main routine, continuing from the statement following the Prog command.
  • Page 30 20- 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 31 20- 11 Command Reference 2. This command can be used to loop back to the beginning of a program or to jump to any location within the program. 3. This command can be used in combination with conditional jumps and count jumps.
  • Page 32 20- 11 Command Reference Parameters: , θ ), numeric constant, variable expression left side/right side: variable (A to Z, (such as: A × 2) , >, <, ≥, ≤ relational operator: =, P.387 G G G G G 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.
  • Page 33 20- 11 Command Reference k k k k k Display Commands (DISP) DispF-Tbl, DispR-Tbl Function: These commands display numeric tables. Syntax: DispF-Tbl_ DispR-Tbl_ Description: 1. These commands generate numeric tables during program execution in accordance with conditions defined within the program. 2.
  • Page 34 20- 11 Command Reference DrawR-Con, DrawR-Plt Function: These commands graph recursion expressions, with ) as the vertical axis and as the horizontal axis. Syntax: DrawR-Con_ DrawR-Plt_ Description: 1. These commands graph recursion expressions, with ) as the vertical axis as the horizontal axis, in accordance with conditions defined within the program.
  • Page 35 20- 11 Command Reference Description: 1. This command graphs convergence/divergence of a recursion expression (WEB graph). 2. Omitting the number of lines specification automatically specifies the default value 30. k k k k k Input/Output Commands (I/O) Getkey Function: This command returns the code that corresponds to the last key pressed.
  • Page 36 (1, 7) → ← (21, 7) Example: Cls_ Locate 7, 1, ”CASIO CFX” This program displays the text “CASIO CFX” in the center of the screen. • In some cases, the ClrText command should be executed before running the above program.
  • Page 37 20- 11 Command Reference Send ( Function: This command sends data to an external device. Syntax: Send (<data>) Description: 1. This command sends data to an external device. 2. The following types of data can be sent by this command. •...
  • Page 38: Text Display

    20-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 ? →...
  • Page 39: Using Calculator Functions In Programs

    20-13 Using Calculator Functions in Programs k k k k k Using Matrix Row Operations in a Program P.80 These commands let you manipulate the rows of a matrix in a program. • 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 40 20- 13 Using Calculator Functions in Programs u u u u u To calculate a scalar multiplication and add the results to another ` ` Row+) row (` Example 3 To calculate the product of Row 2 of the matrix in Example 1 and the scalar 4, then add the result to row 3 The following is the syntax to use for this program.
  • Page 41 20- 13 Using Calculator Functions in Programs 4431 Y = Type_ + 4X + 80” → Y1_ J41JJ ”X ^ 4– X ^ 3– 24X 4411J G SelOn 1_ Orange G1_ !W622 DrawGraph Executing this program produces the result shown here. k k k k k Using Dynamic Graph Functions in a Program P.182 Using Dynamic Graph functions in a program makes it possible to perform...
  • Page 42 20- 13 Using Calculator Functions in Programs k k k k k Using Table & Graph Functions in a Program P.206 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 43 20- 13 Using Calculator Functions in Programs k k k k k Using Recursion Table & Graph Functions in a Program P.218 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 44 20- 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.234 These functions let you sort data in lists into ascending or descending order. •...
  • Page 45 20- 13 Using Calculator Functions in Programs k k k k k Using Statistical Calculations and Graphs in a Program P.250 Including statistical calculations and graphing operations into program lets you calculate and graph statistical data. u u u u u To set conditions and draw a statistical graph Following “StatGraph”, you must specify the following graph conditions: •...
  • Page 46 20- 13 Using Calculator Functions in Programs • The following is a typical graph condition specification for a regression graph. S-Gph1 DrawOn, Linear, List1, List2, List3, Blue _ The same format can be used for the following types of graphs, by simply replacing “Linear”...
  • Page 47 20- 13 Using Calculator Functions in Programs k k k k k Performing Statistical Calculations • Single-variable statistical calculation 1-Variable List 1, List 2 Frequency data (Frequency) x -axis data (XList) 4161 • Paired-variable statistical calculation 2-Variable List 1, List 2, List 3 Frequency data (Frequency) y -axis data (YList) x -axis data (XList)
  • Page 48 20- 13 Using Calculator Functions in Programs • Sine regression statistical calculation SinReg List 1, List 2 -axis data (YList) -axis data (XList) • Logistic regression statistical calculation LogisticReg List 1, List 2 -axis data (YList) -axis data (XList)

Table of Contents