12-3 User-defined Functions

ClassPad lets you configure calculation operations as user-defined functions, which can then be used inside of numeric expressions just like its built-in functions. User-defined functions can also be called up in other applications.

Note

User-defined functions are stored in ClassPad memory as “FUNC” (Function) type variables. Naming, storage, and folder rules are identical to those for user variables.

A user-defined function can contain only a single mathematical expression.

A user-defined function cannot contain any command.

Creating a New User-defined Function

You can use either of the methods below to create user-defined functions.

Using the Program application’s Program Editor window.

Using the Main application’s Define command.

uTo create and save a new user-defined function using the Program Editor window

Example: To create a user-defined function named “f4” that calculates the following: x (x + 1) (x – 2)

1. On the Program Loader or Program Editor window, tap O.

2. On the dialog box that appears, configure the settings for the new file as described below.

• Tap the [Type] down arrow button and then select “Function”.

• Tap the [Folder] down arrow button and then select the folder where you want to save the user-defined function.

• In the [Name] box, input up to eight bytes for the user-defined function name. Here, we will input “f4”.

3. Tap [OK]. This displays a blank Program Editor window.

Parameter variable box

4. Input user-defined function arguments into the parameter variable box. Here, we will input “x”.

5.Input the expression you want. Here, we will input “x (x + 1) (x – 2)”.

6.After the function is the way you want, tap {, or tap [Edit], [Save File] and then [Save] to save it.

uTo create a user-defined function using the Define command

Example: To create a user-defined function named “f2” that calculates the following: 2x + 3y + 1

1.On the Program Loader window, tap ~, or tap O, [Window] and then [Main] to display the Main application window.

You could also tap Mon the icon panel to start up the Main application.

2.Tap [Interactive] and then [Define].

3.On the dialog box that appears, input the following.

[Func name]: “f2”

[Variable/s]: “x, y

[Expression]: 2x + 3y + 1

Chapter 12: Program Application

196