Want to dynamically generate 4D View Pro documents on a server and, for example, send them by email or calculate values? 4D v18 R4 introduces a new command to manipulate 4D View Pro commands in an offscreen area: VP Run offscreen area.
The HDI below demonstrates how to use a 4D View Pro offscreen area and export documents in PDF or MS Excel files:
VP Run offscreen area creates a 4D View Pro area in memory. Simply pass all of the area’s pertinent information in parameter, such as:
- The area name
- The method called when an event is thrown by the 4D View Pro area.
For example if you want to open a 4D View Pro document to retrieve a value, just create a class with the necessary information and a function named “onEvent“. The “onEvent” function is automatically called when an event occurs in the offscreen area. You can manage events with the FORM Event command.
// OffscreenArea class declaration
// This function will be called on each event for the offscreen area
: (FORM Event.code=On VP Ready)
VP IMPORT DOCUMENT (This.area;This.filePath)
This.result:=VP Get value (VP Cell (This.area;6;22))
Instantiate this class and pass it to the VP Run offscreen area:
$result:=VP Run offscreen area ($o)
ALERT("The G23 cell contains the value: "+String($result))
Refer to the documentation for more in-depth information about what you can do with this new command.