0% found this document useful (0 votes)
49 views

CPII Functions and Programs

014

Uploaded by

kamal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views

CPII Functions and Programs

014

Uploaded by

kamal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

ClassPad Help Series - www.classpad.com.au ClassPad Downloads - www.charliewatson.

com/classpad

ClassPad II - How to add your own functions and programs


1. Define new functions in Main
This is useful for simple functions which use a formula to return a single value, such as the nth term of an AP.
Open the Main application. Use the abc tab to enter the function name and don't use a name already
reserved by ClassPad. For variables and expressions, be careful with syntax if you continue to use the abc tab.

Tip:
A user-defined function
can only contain a single
mathematical expression
and must not contain any
commands. You may want
to consult the user
manual: As an example, it
is OK to use binomialCDf,
but not binomialCD, as the
former is a function but
the latter is a command!

Once created in Main, a good idea is to shift functions into the library folder, so that the function can be
accessed from within eActivities, as well as the rest of the calculator.

To delete a function, follow the above steps to move the function, but choose Delete rather than Move as
shown in the fourth image.

If a function doesn't behave as expected, try defining it again. If you use an existing user defined function
name, ClassPad will simply overwrite the old function with the new one.
Watch videos 043, 044, 071
Alternatively, functions can be edited in the Program application. at www.classpad.com.au

© 2015 The Tuition Centre 1 www.thetuitioncentre.com.au


G:\Charlie\Casio\00 Seminars\000 Shift Keys & eAct\CPII_Functions_and_Programs.docx
ClassPad Help Series - www.classpad.com.au ClassPad Downloads - www.charliewatson.com/classpad
From the main menu, open the Program application and tap Edit, Open File. Choose the Type, Folder and
Name of function as illustrated below.

Then tap OK.


Note that this line shows the function name (AP),
the type (F = function) and the required variables
in the order that they should be entered.

Make any corrections or edits to your function and then tap Edit, Save File.

2. Create open programs in eActivity


'Open' programs allow the user to see all the steps involved in producing the end result and allow for easy
modification on the fly. Programs can be written either in the main body of an eActivity or in a Main strip
within an eActivity. In the main body we can add line by line comments to explain our program, although
using strips allows us to store more than one program within an eActivity (but no comments).
Watch video 632 at
Open the eActivity application and start a new eActivity - tap File, New.
www.classpad.com.au

Note how to store multiple variable values using just one line. Also note the difference between a text line, as
selected in first image, and a calculation line, as selected in second image. Use and to toggle
between the two types. Bold selected text using .
A help sheet on creating eActivities is available from the www.charliewatson.com/classpad.

© 2015 The Tuition Centre 2 www.thetuitioncentre.com.au


G:\Charlie\Casio\00 Seminars\000 Shift Keys & eAct\CPII_Functions_and_Programs.docx
ClassPad Help Series - www.classpad.com.au ClassPad Downloads - www.charliewatson.com/classpad
3. Create simple programs in Program.
For this example, we'll calculate the coefficients of the nth row of Pascal's Triangle - useful for binomial
expansions, etc. Open the Program application and tap Edit, New File. Enter a name - PT - and tap OK.

Notes

• This program has just one input variable, n


• Lines starting with an apostrophe are ignored
• Start a new line by pressing the EXE key

Local variables are used only within program and then


cleared.

ClrText clears the result screen.

Print writes values and text to the result screen.

Return writes variables to the main screen, when


program is run in main.

Once your code has been entered, tap Edit, Save File and then tap . Check that the name of the current
program is PT, enter 4 as the parameter (n) and tap . If all goes well, the Status box appears with the
message 'Done' and you can tap OK. Tap to return to the program application.

This program PT has no data input


validation to prevent errors and the
output is very basic.

Consult the program chapter in the


ClassPad manual for methods to handle
more complex text output, including
functions to handle strings.

Watch video 985 at


www.classpad.com.au

Tap Edit, Open Editor to edit your program. Choose Compress to reduce file size and prevent further editing
(you will be prompted to save an editable backup).

In the variable manager, within the main folder, you should find PT, PTedit and p amongst the variables.
Delete, move and rename your program from here.

© 2015 The Tuition Centre 3 www.thetuitioncentre.com.au


G:\Charlie\Casio\00 Seminars\000 Shift Keys & eAct\CPII_Functions_and_Programs.docx
ClassPad Help Series - www.classpad.com.au ClassPad Downloads - www.charliewatson.com/classpad
Additional programming tips - Ctrl and I/O Menus

If ... Then ... Else ... IfEnd Program takes two Else is optional.
Use for branching and values and prints out the
decision making. difference. Can also include ElseIf
statement.

For ... Next Program sums the Can add 'Step k' to
Use for repeating fixed squares of all integers increment i in steps of k.
number of times from 1 to n.

Do ... LpWhile Programs finds the Beware of writing an


Use for looping until a smallest number which endless loop! Press the
condition is met. has a square greater Clear button to break out
than n. of such a program.

While ... WhileEnd Program sums the roots Again, beware of endless
Use for looping, but of integers from 1 to n. loops.
checks for condition at
start of loop.

Input Program displays all Note use of colons to


Use for obtaining a factors of any integer. enter multiple
single number input commands on a single
from user. line.

Locate This program prints the x: 1 to 290


Use for writing to squares of numbers from y: 1 to 290
specific location (x,y) on 1 to n at the location Upper left corner is (1,1)
the screen. (1, 20) on the screen.

PrintNatural and In Main, check the setup is Standard rather than


Message Decimal. Run the program by entering a decimal
Pause and display result. number. The program displays the decimal as a
fraction and then the message "Finished".

InputFunc Program displays value


Use for obtaining a of function for x=-2 to 2
function from the user. and then finds roots.

© 2015 The Tuition Centre 4 www.thetuitioncentre.com.au


G:\Charlie\Casio\00 Seminars\000 Shift Keys & eAct\CPII_Functions_and_Programs.docx

You might also like