Identifier: funcval[ ]

Type

generic

Description

Returns the value of the current function. This identifier only has meaning within a user function and provides the means of communicating the function value (or values) back to the command which invoked the function. The type of funcval will vary and corresponds to the type of function in which it is active. At the beginning of function execution funcval has a null value.

funcval is treated as a variable length array of initial length of 1. This enables multiple values to be returned to the caller.

Examples

Define a string function which transfers the extension from one file name to another (unless it has no extension).

string_function xferext {
    args oldname=string, newname=string
    string newext = fext(newname)
    if (newext) funcval = chext(oldname,newext)
    else funcval = oldname
}

Use of the function ...

tell xferext(myfile,newfile)

Define a point function which returns the three points at quarter intervals between two given points.

point_function qpts {
    args p1=point, p2=point
    funcval[2] = midp(p1,p2)
    funcval[1] = midp(p1,funcval[2])
    funcval[3] = midp(funcval[2],p2)
}

Use of the function ...

!Indicate two points via the mouse
tell <'Quarter points:',qpts(pcur,pcur)>

Notes

To return an empty funcval array, i.e. an array of 0 length, the length of funcval should be manually set to 0, since funcval has a default length of 1, e.g.

funcval.alength = 0

or

delid funcval[1:*]