This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com

Home

 
4D v19
VP Run offscreen area

VP Run offscreen area 


 

VP Run offscreen area ( parameters ) -> Function result 
Parameter Type   Description
parameters  Object in Object containing the offscreen area's attributes
Function result  Mixed in .result property of the onEvent object, or Null if does not return a value

The VP Run offscreen area command creates an offscreen area in memory which can be used to process 4D View Pro area commands and functions. 

In parameters object, pass any of the following optional properties. These properties will be available through the This command within the onEvent method and reference the instance: 

 

Property  Type  Description
area  text  The name of the offscreen area. If omitted or null, a generic name is assigned (e.g., OffscreenArea1). 
onEvent  object (formula) A callback method that will be launched when the offscreen area is ready. It can be either:
  • an onEvent function of a class, or
  • a Formula object
By default, the callback method is called on the On VP Ready, On Load, On Unload, On End URL Loading, On URL Loading Error, On VP Range Changed, or On Timer events. 

The callback method can be used to access the 4D View Pro object. See 4D View Pro form object variable.
autoQuit  boolean  True (default value) if the command must stop the formula execution when the On End URL Loading or On URL Loading Error events occur.

If false, you must use the CANCEL or ACCEPT commands in the onEvent callback method. 
timeout  real  Maximum time (expressed in seconds) before the area automatically closes if no event is generated. If set to 0, no limitation is applied. Default value: 60 
result mixed Result of the processing (if any)
<customProperty>  mixed  Any custom attribute to be available in the onEvent callback method. 

 

The following property is automatically added by the command if necessary: 

 

Property  Type  Description 
timeoutReached boolean  Added with true value if timeout has been exceeded

 

Note: The offscreen area is only available during the execution of the VP Run offscreen area command. It will automatically be destroyed once execution has ended.

 

The following commands can be used in the callback method:

You want to create an offscreen 4D View Pro area and get the value of a cell:

 

  // OffscreenArea class declaration 
 Class constructor
 C_TEXT($1)
 This.filePath:=$1
 
  // This function will be called on each event of the offscreen area 
 Function onEvent
 Case of
    :(FORM Event.code=On VP Ready)
       VP IMPORT DOCUMENT(This.area;This.filePath)
       This.result:=VP Get value(VP Cell(This.area;6;22))
 
       ALERT("The G23 cell contains the value: "+String(This.result))
 End case

 

the OffscreenArea callback method:  

 

 $o:=cs.OffscreenArea.new()
 
 $result:=VP Run offscreen area($o)

 

You want to load a large document offscreen, wait for all calculations to complete evaluating, and export it as a PDF: 

  //OffscreenArea class declaration
 class constructor($pdfPath Text)
 This.pdfPath:=$pdfPath
 This.autoQuit:=False
 This.isWaiting:=False
 
 Function onEvent
 Case of
    :(FORM Event.code=On VP Ready)
  // Document import
       VP IMPORT DOCUMENT(This.area;$largeDocument4VP)
       This.isWaiting:=True
 
  // 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.
       SET TIMER(60)
 
    :(FORM Event.code=On VP Range Changed)
  // End of calculation detected. Restarts the timer
       If(This.isWaiting)
          SET TIMER(60)
       End if
 
    :(FORM Event.code=On Timer)
  // To be sure to not restart the timer if you call others 4D View command after this point
       This.isWaiting:=False
 
  // Stop the timer
       SET TIMER(0)
 
  // Start the PDF export
       VP EXPORT DOCUMENT(This.area;This.pdfPath;New object("formula";Formula(ACCEPT)))
 
    :(FORM Event.code=On URL Loading Error)
       CANCEL
 End case

 

the OffscreenArea callback method:  

 

 $o:=cs.OffscreenArea.new()
 
 $result:=VP Run offscreen area($o)

 



See also 

Blog post: End of document loading

 
PROPERTIES 

Product: 4D
Theme: 4D View Pro Language
Number: 905271

 
PAGE CONTENTS 
 
HISTORY 

Created: 4D v18 R4

 
ARTICLE USAGE

4D View Pro Reference ( 4D v19)