4D View Pro is getting more feature-rich with every R-release and 4D v17 R6 is no exception! A new command is available which allows you to specify a 4D method’s parameters, name, type, and a summary. Now your methods can be more informative and descriptive, helping end users to use them correctly.
Do you want to declare a date or time? What about giving a short description to help users understand what the method does? It can now be done with VP SET ALLOWED METHODS command!
What better way to understand the use of this command than an example? By the time you’ve finished reading and following the example steps, you’ll be able to get the result below:
A step by step example
The VP SET ALLOWED METHODS command provides a new way to allow your 4D methods. Below demonstrates how to proceed if you want to call the “Birth Information” method in a 4D View Pro formula:
// Create a string from parameters
$0:=$1+" was born on "+String($2)+" at "+String($3)
How to Allow a method
Create an object and use the object’s attribute to define your method’s call name:
// Name of the method in 4D View Pro: "Birth Information"
Then in the $o.BIRTH_INFORMATION object, define the called 4D method:
Add name and type for each parameter
Add a collection with information about the method’s parameters:
$o.BIRTH_INFORMATION.parameters.push(New object("name";"First name";"type";Is text))
$o.BIRTH_INFORMATION.parameters.push(New object("name";"Birthday";"type";Is date))
$o.BIRTH_INFORMATION.parameters.push(New object("name";"Time of birth";"type";Is time))
Add a summary
Specify a summary of what your command does:
$o.BIRTH_INFORMATION.summary:="Returns a string from birth information"
Specify the number of parameters
Finally, you can limit the number of arguments in your 4D View Pro formula by adding minimum and maximum values. For example, if all of the parameters are mandatory:
You can create as many attributes as a method requires, then pass the method object ($o) to the VP SET ALLOWED METHODS command:
VP SET ALLOWED METHODS ($o)