When you use 4D View Pro (especially in offscreen mode) with complex documents, calculating all formulas could take a while and it can be difficult to know when it’s finally finished (and it’s important to wait before you call commands such as export or print).
As a solution, we’ve introduced two new events. One of which is called for every single calculation/formula, which could be used to trigger a timer. If the time expires without another formula being finished, we can assume that the whole document is finished.
The first event is On VP Range Changed. This event is launched each time a calculation is completed. Since there can be several calculations, the second event is the on Timer event. This event allows you to wait until the next calculation is completed. If an On VP Range Changed event is thrown before the end of the timer, restart it, otherwise, it’s finished.
For example, if you want to load a large document, wait for the end of all calculations, and export it, you’ll need to create this type of class:
Class constructor($pdfPath : Text)
: (FORM Event.code=On VP Ready)
// Document import
VP IMPORT DOCUMENT(This.area; $largeDocument4VP)
// Start a timer to verify if all calculations are finished.
// If during this period the "On VP Range Changed" is thrown, the timer will be restarted
// The time must be defined according to the computer configuration.
: (FORM Event.code=On VP Range Changed)
// End of calculation detected. Restart the timer
: (FORM Event.code=On Timer)
// To make sure not to restart the timer if you call other 4D View commands after this point
// Stop the timer
// Start the PDF export
VP EXPORT DOCUMENT(This.area; This.pdfPath; New object("formula"; Formula(ACCEPT)))
: (FORM Event.code=On URL Loading Error)
Download the HDI above to see how to use these events to export a large 4D View Pro file in PDF format!
And check out the doc center for more details!