4D View Pro automatically recalculates the formulas in your worksheet when you change data they depend on (e.g., entries, formulas, names, etc.).
But what if you want to make your UI more interactive and trigger the calculation of formulas whenever you want? 4D v18 R4 makes it possible thanks to three new commands: VP SUSPEND COMPUTING, VP RESUME COMPUTING, and VP RECOMPUTE FORMULAS. These commands let you suspend and resume the calculation of all formulas in your document, or force their recalculation.
The HDI below demonstrates how to recalculate formulas after loading a record from the database and how to stop/resume the calculations in a document.
When you use data from 4D (e.g., variables through methods or database fields), you need to refresh your formulas when this data changes. To do so, just use this line of code:
VP RECOMPUTE FORMULAS ("ViewProArea")
suspend and resume formula COMPUTING
For example, to avoid calculation errors in your cells such as “#DIV/0!” while you’re still working on the document, use this code:
- suspend the calculations in the document:
VP SUSPEND COMPUTING ("ViewProArea")
- add your values or formulas in the cells
- resume calculations:
VP RESUME COMPUTING ("ViewProArea")
In the same way, you can save time and be more efficient with large documents: manage the calculation of your formulas whenever you want!