C-PLOT

Scientific Graphics and Data Analysis

11.2. - fn, fO# run a user function



User functions provide a general purpose interface to read in data, generate new data or modify current data. With user functions, you also can control many of the features of the plot, including values of the axis ranges and the text used for plot labels.

In the simplest case, you give the program the name of a function and its type, and the program leads you through the creation, editing and compiling of the function.
fn
fn name.# [start finish intervals]
fn name.#.c
fn .
fn c
fn e
fn k
fn ?
f1 (same options)
or
f# (same options)
With no arguments, these commands prompt you for the function type and the function name. If the function is not found using the search rules described above, you are asked if you wish C-PLOT to create a new prototype. If the prototype already exists, but not in an executable version, you are asked if you wish to edit the prototype.

If the executable version exists, but the date of the prototype is more recent than the executable, you are asked if you wish to recompile the prototype. Otherwise, the executable version is run.

If, when the user function returns, it is found to be not compatible with the current version of C-PLOT, you will be informed. You should then recompile the prototype.

If you wish to first edit an existing function, specify the name with the .c extension and the program will invoke the editor.

If you already have a function running, typing fn . will return you to it. The program will automatically start up the editor for the current function if you type fn e. If you type fn c the program will automatically recompile the current function.

If a function dies unnaturally on receipt of a signal (floating point exception, segmentation violation, etc.), C-PLOT will print a message informing you of that fact along with the number of the signal.

Type 1 and 2 functions require a range on which to calculate the data. If you don't enter the starting value, finishing value and number of intervals on the command line, you will be asked for them. Note that the number of points generated is one more than the number of intervals. For type 1 functions, the range is in the independent variable, x. For type 2 functions, the range is for the parametric variable, t. In either case, if you specify a negative number for the number of intervals, the spacing of the points over the range will be logarithmic.

When type 1, 2 and 3 functions are executing, typing a ^C will cause each point to be printed out. Typing a second ^C will cause an immediate return from the function. A single ^C makes a type 4 function return immediately.

When you type fn name.#, the function starts executing from scratch.

C-PLOT lets you keep eight functions going independently. The fn command is synonymous with f1. The f2 command refers to the second function. The f3 command refers to the third function, etc., up to f8. Typing fn k kills the current function process. The ? option displays the function number, process ID number and name of each active user function.

See Appendix E for more information on writing type 1 through 4 functions. For examples of user functions, see the source code for C-PLOT's standard included functions in $CPLOTHOME/functions .

Type 5 functions, the nonlinear least-squares fits, are described in detail in Chapter 12.