Aller au contenu principal
Version: 20 R6

VP SET CUSTOM FUNCTIONS

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

ParamètresTypeDescription
vpAreaNameText->Nom d'objet formulaire zone 4D View Pro
formulaObjObject->Objet formule

Description

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.

The formulas specified by VP SET CUSTOM FUNCTIONS appear in a pop-up menu when the first letter of their name is entered. 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.

Passez le nom de la zone 4D View Pro dans vpAreaName. Si vous passez un nom inexistant, une erreur est retournée.

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.

PropriétéTypeDescription
<customFunction>ObjectDescription de la fonction personnalisée. <customFunction> defines the name of the custom function to display in 4D View Pro formulas (no spaces allowed)
formulaObjectObjet formule 4D (obligatoire). See the Formula command.
parametersCollection d'objetsCollection de paramètres (dans l'ordre dans lequel ils sont définis dans la formule). For more information, please refer to the Parameters section.
[ ].nameTextNom du paramètre à afficher dans 4D View Pro
[ ].typeNumberType de paramètre. 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.
    summaryTextDescription de la formule à afficher dans 4D View Pro
    minParamsNumberNombre minimum de paramètres
    maxParamsNumberNombre maximum de paramètres. Passing a number higher than the length of parameters allows declaring "optional" parameters with default type

    WARNING

    • 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.

    Exemple

    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

    Voir également

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