This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v19
VP SET CUSTOM FUNCTIONS
|
VP SET CUSTOM FUNCTIONS ( vpAreaName ; formulaObj ) | ||||||||
Parameter | Type | Description | ||||||
vpAreaName | Text |
![]() |
4D View Pro area form object name | |||||
formulaObj | Object |
![]() |
Formula object | |||||
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 Entering a Formula, a Function or a Reference.
Note: 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.
Pass the name of the 4D View Pro area in vpAreaName. If you pass a name that does not exist, an error is returned.
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.
Property | Type | Description | ||||||||||
<customFunction> | Object | Custom functions to define in 4D View Pro | ||||||||||
formula | Object | 4D formula object (mandatory). See Formula | ||||||||||
parameters | Collection of objects | Collection of parameters (in the order they are defined in the formula) | ||||||||||
[ ].name | Text | Name of parameter to display in 4D View Pro | ||||||||||
[ ].type | Number | Type of the parameter. Supported types:
If type is omitted or if the default value (-1) is passed, the value is automatically sent with its type, except date or time values which are sent as an object (see Parameters section). If type is Is object, the object has the same structure as the object returned by VP Get value. | ||||||||||
summary | Text | Formula description to display in 4D View Pro | ||||||||||
minParams | Number | Minimum number of parameters | ||||||||||
maxParams | Number | Maximum number of parameters. Passing a number higher than the length of parameters allows declaring "optional" parameters with default type |
WARNING
You want to use formula objects in a 4D View Pro area to add numbers, retrieve a customer's last name and gender:
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 longint))
$o.addnum.parameters.push(New object("name";"num2";"type";Is longint))
// 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 longint))
// 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
Field references
Project method references
VP SET ALLOWED METHODS
Product: 4D
Theme: 4D View Pro Language
Number:
905272
Created: 4D v18 R5
4D View Pro Reference ( 4D v19)