Aller au contenu principal
Version: 20 R5 BETA

VP Run offscreen area

VP Run offscreen area ( parameters : Object) : Mixed

ParamètresTypeDescription
parametersObject->Objet contenant les attributs de la zone hors écran
RésultatMixed<-.result property of the .onEvent object, or Null if does not return a value

Description

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:

PropriétéTypeDescription
areatextLe nom de la zone hors écran. S'il est omis ou null, un nom générique est assigné (ex : OffscreenArea1).
onEventobjet (formula)Une méthode callback qui sera lancée lorsque la zone hors écran sera prête. 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 form object variable.
    autoQuitbooleanTrue (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.
    timeoutnumberDurée maximale (exprimée en secondes) avant la fermeture de la zone si aucun événement n'est généré. Si elle est fixée à 0, aucune limitation n'est appliquée. Valeur par défaut : 60
    resultmixteRésultat du traitement (le cas échéant)
    <customProperty>mixteAny custom attribute to be available in the onEvent callback method.

    La propriété suivante est automatiquement ajoutée par la commande, si nécessaire :

    PropriétéTypeDescription
    timeoutReachedbooleanAjouté avec la valeur vrai si le timeout a été dépassé

    The offscreen area is only available during the execution of the VP Run offscreen area command. Elle sera automatiquement détruite à la fin de l'exécution.

    Les commandes suivantes peuvent être utilisées dans la méthode callback (de rétro-appel) :

    • ACCEPT
    • CANCEL
    • SET TIMER
    • WA Evaluate JavaScript
    • WA EXECUTE JAVASCRIPT FUNCTION

    Exemple 1

    Vous souhaitez créer une zone 4D View Pro hors écran et lire la valeur d'une cellule :

    // cs.OffscreenArea class declaration 
    Class constructor ($path : Text)
    This.filePath:=$path

    // 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)

    Exemple 2

    Vous souhaitez charger un grand document hors écran, attendre que tous les calculs soient terminés et l'exporter au format PDF :

    //cs.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)

    Voir également

    Blog post: End of document loading