Custom Functions

The formula compiler detects evaluation dependency by identifying the places where value of a cell variable is retrieved. For example, with the following formula, you need to compute “Scrap Units” before you compute “Scrap Cost”

"Scrap Cost" = ComponentMetrics.standardCost  * "Scrap Units"

However, if a function takes a parameter of Location type, the compiler does not known whether the function implementation takes the metadata of the location only, or it takes its value also. The protocol described as following serves such a purpose.

If a custom function reads values from some cell locations rc1, rc2, …, rcm, from the current block and writes into some cell locations, wc1, wc2, …, wcn, in the current block, you need to know that during evaluation dependency analysis. In this case, you need to have rc1, rc2, …, rcm evaluated first before this customer function is called. Create a HashMap instance, which has each rci as key and a HashSet instance with wc1, …, wcn as the value.