The Functions tab is added to the Script Editor to define a new function.
For example, let us create a simple function to display a number. Specify the function name as display. Since this function does not return any argument, the return type is void. Argument a of type int, will be passed to this function, when called. Create the function by selecting the Create the Function button.
The function display will be added to the Functions tree under the namespace test, as shown in the screen-shot below. Select the function from the Functions tree and add the required deluge statements to be executed, using drag-n-drop or Free-flow scripting. For example, we add the Deluge statement Info to display a given number. Select Save Script to save the function.
You can use the Execute Script option to test if your function is executed as defined, by specifying the required values as arguments to the function. For example, to execute the display function, we specify a value for the argument (int a). On submit, the Info input.a deluge statement is executed , as shown in the screen-shot below:
Zoho Creator supports Form Objects that can be passed as argument to a user-defined Function. A Form Object represents a collection of records in a Form. Refer the topic Passing Form object as argument to the function, for more information.
In the screen-shot given below, Calculations is the namespace that groups similar functions related to calculations. Here, CalculateDays, CalculateHours etc are function names. If the function is called within the application where it is defined, the namespace will be appended with the word thisapp. If the function is called from a different application, the namespace will be appended with the actual application name, where it is defined.
For example, if the function CalculateDays is called from the Sample application, the function call will be in the following format: thisapp.Calculations.CalculateDays(),
- thisapp refers to the current application,
- Calculations is the namespace,
- CalculateDays is the function name.