Saltar para o conteúdo principal
Versão: 20 R6 BETA

VP SET CUSTOM FUNCTIONS

VP SET CUSTOM FUNCTIONS ( vpAreaName : Text ; formulaObj : Object )

ParâmetroTipoDescrição
vpAreaNameText->Nome de objeto formulário área 4D View Pro
formulaObjObject->Objecto fórmula

Descrição

The VP SET CUSTOM FUNCTIONS command designates the 4D formulas that can be called directly from 4D View Pro formulas. Because custom functions are not stored in the document,VP SET CUSTOM FUNCTIONS must be executed in the On Load form event.

As fórmulas especificadas por VP SET CUSTOM FUNCTIONS aparecem em um menu pop-up quando a primeira letra de seu nome é inserida. See the Formulas and Functions page.

If VP SET CUSTOM FUNCTIONS is called multiple times for the same area, in the same session, only the last call is taken into account.

Passe o nome da área 4D View Pro em vpAreaName. Se passar um nome que não existe, é devolvido um erro.

In the formulaObj parameter, pass an object containing the 4D formulas that can be called from 4D View Pro formulas as well as additional properties. Each customFunction property passed in formulaObj becomes the name of a function in the 4D View Pro area.

PropriedadeTipoDescrição
<customFunction>ObjectDefinição da função personalizada. <customFunction> defines the name of the custom function to display in 4D View Pro formulas (no spaces allowed)
formulaObjectObjeto fórmula 4D (obrigatório). Ver o comando Formula.
parametersUma coleção de objetosColeção de parâmetros (pela ordem em que são definidos na fórmula). For more information, please refer to the Parameters section.
[ ].nameTextNome do parâmetro a mostrar no 4D View Pro
[ ].typeNumberTipo do parâmetro. Supported types:
  • Is Boolean
  • Is collection
  • Is date
  • Is Integer
  • Is object
  • Is real
  • Is text
  • Is time
  • type can be omitted or the default value (-1) can be passed (except when at least one parameter is of collection type, in which case parameter's type declaration is mandatory).
    If type is omitted or -1, the value is automatically sent with its type, except date or time values which are sent as an object. If type is Is object, the object is sent in a .value property. See Parameters section.
    resumoTextDescrição da fórmula a mostrar no 4D View Pro
    minParamsNumberNúmero mínimo de parâmetros
    maxParamsNumberNúmero máximo de parâmetros. Passing a number higher than the length of parameters allows declaring "optional" parameters with default type

    AVISO

    • As soon as VP SET CUSTOM FUNCTIONS is called, the methods allowed by the VP SET ALLOWED METHODS command (if any) are ignored in the 4D View Pro area.
    • As soon as VP SET CUSTOM FUNCTIONS is called, the functions based upon SET TABLE TITLES and SET FIELD TITLES commands are ignored in the 4D View Pro area.

    Exemplo

    You want to use formula objects in a 4D View Pro area to add numbers, retrieve a customer's last name and gender and the company's peak month:

    Case of
    :(FORM Event.code=On Load)

    var $o : Object
    $o:=New object

    // Define "addnum" function from a method named "addnum"
    $o.addnum:=New object
    $o.addnum.formula:=Formula(addnum)
    $o.addnum.parameters:=New collection
    $o.addnum.parameters.push(New object("name";"num1";"type";Is Integer))
    $o.addnum.parameters.push(New object("name";"num2";"type";Is Integer))

    // Define "ClientLastName" function from a database field
    $o.ClientLastName:=New object
    $o.ClientLastName.formula:=Formula([Customers]lastname)
    $o.ClientLastName.summary:="Lastname of the current client"

    // Define "label" function from a 4D expression with one parameter
    $o.label:=New object
    $o.label.formula:=Formula(ds.Customers.get($1).label)
    $o.label.parameters:=New collection
    $o.label.parameters.push(New object("name";"ID";"type";Is Integer))

    // Define "AverageValues" function from a method named "AverageValues"
    $o.AverageValues:=New object
    $o.AverageValues.formula:=Formula(AverageValues)
    $o.AverageValues.parameters:=New collection
    $o.AverageValues.parameters.push(New object("name";"Mycollection";"type";Is collection))

    // Define "Title" function from a variable named "Title"
    $o.Title:=New object
    $o.Title.formula:=Formula(Title)

    VP SET CUSTOM FUNCTIONS("ViewProArea";$o)

    End case

    Veja também

    4D functions
    VP SET ALLOWED METHODS
    4D View Pro: enhancement of custom functions (blog post)