Saltar para o conteúdo principal
Versão: Próximo

VP Run offscreen area

VP Run offscreen area ( parameters : Object) : Mixed

ParâmetroTipoDescrição
parametersObject->Objeto que contém os atributos da área fora do ecrã
ResultadosMixed<-.result property of the .onEvent object, or Null if does not return a value

Descrição

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:

PropriedadeTipoDescrição
areatextO nome da área offscreen. Se omitido ou nulo, um nome genérico é atribuído (por exemplo, "OffscreenArea1").
onEventobject (fórmula)Um método de callback que será iniciado quando a área fora da tela estiver pronta. 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.
    timeoutnumberTempo máximo (expresso em segundos) antes que a área seja encerrada automaticamente, se nenhum evento for gerado. Se for definido para 0, não é aplicada qualquer limitação. Valor por padrão: 60
    resultmistoResultado do processamento (se for caso disso)
    <customProperty>mistoAny custom attribute to be available in the onEvent callback method.

    A seguinte propriedade é automaticamente adicionada pelo comando, se necessário:

    PropriedadeTipoDescrição
    timeoutReachedbooleanAdicionado com valor true se o tempo limite tiver sido excedido

    A área fora da tela só está disponível durante a execução do comando VP Run offscreen area. Ele será destruído automaticamente após o término da execução.

    Os seguintes comandos podem ser utilizados no método de retorno de chamada:

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

    Exemplo 1

    Se quiser criar uma zona fora da área da tela do 4D View Pro e ler o valor de uma célula:

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

    Exemplo 2

    Se quiser carregar um grande documento offscreen, aguardar todos os cálculos para concluir a avaliação e exportá-lo como um 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)

    Veja também

    Blog post: End of document loading