Attributes of a function

Revision as of 19:08, 16 May 2016 by Bbecane (talk | contribs)


Like other objects, a function is defined by a set of attributes. It shares many of the attributes of variables, including identifier, title, units, description, and definition, inputs, and outputs. It has a unique attribute, Parameters, which specifies the parameters available to the function.

Identifier

If you are creating a library of functions, make a descriptive identifier. This identifier appears in the function list for the library under the Definition menu, and is used to call the function. Analytica makes all characters except the first one lower case.

Title

If you are creating a library of functions, limit the title to 22 characters. This title appears in the Object Finder dialog to the right of the function.

Units

If desired, use the units field to document the units of the function’s result. The units are not used in any calculation.

Parameters

The parameters to be passed to the function must be enclosed in parentheses, separated by commas. For example:

(x, y, z: Number)

The parameters can have type qualifiers, such as Number above (see the next section). Index parameters must have the Index qualifier, otherwise their value is passed and the parameter name cannot be used as an index in the function’s Definition.

You can help make functions easier to understand and use by giving the parameters meaningful names, in a logical sequence. The parameters appear in the Object Finder dialog. When you select a function from the Definition menu]], it copies its name and parameters into the current definition.

Description

The description should describe what the function returns, and explain each of its parameters. If the definition is not immediately obvious, a second part of the description should explain how it works. The description text for a function in a library also appears in a scrolling box in the bottom half of the Object Finder dialog.

Definition

The definition of a function is an expression or compound list of expressions. It should use all of its parameters. When you select the definition field of a function in edit mode, it shows the Inputs pull-down menu that lists the parameters as well as any other variables or functions that have been specified as inputs to the function. You can specify the inputs to a function in the same way as for a variable, by drawing arrows from each input node into the function node.

Recursive

Set to 1 (true) if the function is recursive — that is, it calls itself. This attribute is not initially displayed. Use the Attributes dialog from the Object menu to display it. See For and While Loops and Recursion.

See Also


Comments


You are not allowed to post comments.