4D View Pro: End of document loading

Automatically translated from English

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.

HDI 4DVP End Loading

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)
Function onEvent
Case of
: (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
  If (This.isWaiting)
    SET TIMER(60)
  End if
: (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)
End case 

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!

Fabrice Mainguené

• Product Owner •

Fabrice Mainguené joined 4D Program team in November, 2016. As a Product Owner, he is in charge of writing the user stories then translating it to functional specifications. His role is also to make sure that the feature implementation delivered is meeting the customer need.

After obtaining a Bachelor degree in Computer Science at CNAM, Fabrice joined a small software publishing company as a Windev developer. Then he worked for different companies in industry and trade areas as a Windev and web developer as well as technical advisor on new features.