RAD function: cleanup

A RAD function that frees the storage associated with a variable.

Function

cleanup

Format

cleanup($filename, [$fieldname], [index])

Parameters

The following parameters are valid for this function.

Parameter

Description

$filename

The variable that you want to clean up.

If only $filename is specified, this variable can be a file variable or a field.

[$fieldname]

Optional.

When specified, indicates the name of a field whose field value and display value (if any) are to be cleaned up.

Note Fields that have a referenced table defined have a display value.

[index]

Optional.

If the field specified in $fieldname is of the array type, the value and display value (if any) of the element that has the specified index or position number in that array are cleaned up.

Factors

If only $filename is specified when calling this function, this function returns the same result as it would in versions earlier than 9.41.

This function does not return a value. It cleans up (empties) the variable or field specified by setting the value to NULL.

You can use this function on any variable type (local, thread, or global), but it is generally used on local and thread variables to clean up values before a user logs out.

This is the preferred way to clean up both variables and fields in records as opposed to $x=NULL or field in $file=NULL.

Unless you run this function, variables remain in memory until their defining environment ends.

For local variables, this is the parent RAD program. For thread variables, this is the parent RAD thread. For global variables, this is the user session.

Note This RAD function is not available as a JavaScript system.functions call.

Return values

None

Examples

cleanup($file)
cleanup($file, “logical.name”)
cleanup($file, “assets”, 0)