The cache( function stores a value in a temporary variable.


This function has two parameters:

value – The value to be stored in the variable. This value is also returned as the result of the function.

variable – The name of the temporary variable to store the value into. If this temporary variable does not exist, it will be created. The variable name must be quoted.


This function stores a value in a temporary variable. This variable is very shortlived, in fact it only lasts up to the end of the formula. You can use this function to cache a value so it can be used more than once in the formula without having to recalculate it. For example you might use this function to store the result of a regular expression if you want to use the regular expression result more than once in the formula.

The temporary variables created by this function have the highest precedent of any type of variable. For example if you create a temporary variable named A, you will not be able to access a local variable named A within the formula, or a fileglobal or global variable, or even a database field named A. So be sure to pick a temporary variable name that does not conflict with any other variable or field names used in the formula. (It doesn’t matter if a temporary variable name conflicts with a field or variable that is not actually used in the formula.)

In addition to storing the value in the temporary variable, the cache( function also returns the VALUE parameter as its value. If you don’t want to use this value in your formula use the ignore( function.

This example shows a typical use for the cache( function. The formula uses the regexarray( function to extract a list of e-mail addresses from the text. However, the formula needs this list twice – once to calculate the number of e-mail addresses (using arraysize(), and once to display the list itself. Instead of calculating the regular expression twice, the formula simply caches the regular expression result in a temporary variable named EMAILS.

"This text contains "+
arraysize(cache(regexarray("Reply to or",
"([\w!#$%&'*+/=?`{|}~^.-]+)@([A-Z0-9.-]+)",","),"EMAILS"),",")+" emails: "+ EMAILS
    ☞ This text contains 2 emails:,

Remember, the temporary variable EMAILS is only available in the formula itself. You can’t access it anywhere else. If you want to be able to access a stored value later you should use the assign( or assignglobal( functions.

See Also


10.0NewNew in this version.