VP SET CUSTOM FUNCTIONS
VP SET CUSTOM FUNCTIONS ( vpAreaName : Text ; formulaObj : Object )
Parâmetro | Tipo | Descrição | ||
---|---|---|---|---|
vpAreaName | Text | -> | Nome de objeto formulário área 4D View Pro | |
formulaObj | Object | -> | 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. Veja a página Fórmulas e Funções.
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.
Propriedade | Tipo | Descrição | ||
---|---|---|---|---|
<customFunction> | Object | Definição da função personalizada. <customFunction> defines the name of the custom function to display in 4D View Pro formulas (no spaces allowed) | ||
formula | Object | Objeto fórmula 4D (obrigatório). Ver o comando Formula . | ||
parameters | Uma coleção de objetos | Coleção de parâmetros (pela ordem em que são definidos na fórmula). For more information, please refer to the Parameters section. | ||
[ ].name | Text | Nome do parâmetro a mostrar no 4D View Pro | ||
[ ].type | Number | Tipo do parâmetro. Supported types:Is Boolean Is collection Is date Is Integer Is object Is real Is text Is time 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. Se type é Is object , o objeto é enviado em uma propriedade .value . Consulte a seção Parâmetros. | ||
resumo | Text | Descrição da fórmula a mostrar no 4D View Pro | ||
minParams | Number | Número mínimo de parâmetros | ||
maxParams | Number | Nú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 uponSET TABLE TITLES
andSET 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)