Using Functions in Procedures
A function, also known as a case, is a series of commands in a procedure grouped together as a unit of control. A function accomplishes a task, such as calculating values, extracting data from a data source to place in a data source stack, or writing information to a data source. You can also call one function from within another function.
- All executable code must be in a function. The only types of logic allowed outside of a function are variable declarations, object declarations, and class definitions (CASE, DECLARE, DESCRIBE, END, MAINTAIN, and MODULE statements).
- Some functions have arguments, meaning when you invoke the function, you must supply the information that the function needs to complete its task.
- Some functions also have a return value, meaning they calculate a value and return this value to whatever called the function. Functions that are event handlers (that is, that are invoked by some action in a form) cannot have return values.
- The combination of the arguments and the return value of a function is known as its signature.
- Local variables (defined in a function using the DECLARE command) are available only within that function. As soon as the function completes processing, these values are no longer available.
- Global variables (defined using the DECLARE command outside
of a function or using the COMPUTE command anywhere) are available
for the entire procedure.
Note: For more information on local and global variables, see the WebFOCUS App Studio Maintain Data Language Reference content.
Create a Function
- Procedure
- Select the procedure that you would like the new function to be part of.
- Right-click the procedure and click New function in the shortcut menu.
- In the New Function dialog box, type a name for your function in the Name field (up to 66 characters with no spaces).
- Use the New button to open the Function Parameter dialog box to add any arguments (not all functions require arguments).
- Use the Returns field to enter the name and format of a return value (not all functions require return values). You can also click the ellipsis button to open the Function Return dialog box. This is where you can define the function.
- Click the Description tab, type a description, and click OK. (Optional)
- Right-click the function and select Edit Source from
the shortcut menu.
The Maintain Data Editor opens the procedure containing your function in the code for the function.
- Locate your cursor just before the ENDCASE keyword and
enter the Maintain Data language commands that determine what this
function does.
Note: The following Maintain Data language commands are not valid within the context of a function: CASE, ENDCASE, MAINTAIN, END, MODULE, and DESCRIBE.Tip: You can add Maintain Data language code to your function using the Language Wizard. Place your insertion point where you want your code to go, right-click in the Maintain Data Editor window and select Language Wizard in the shortcut menu.
Edit a Function
- Procedure
- Right-click the function in the Requests & Data Sources panel.
- Click Edit Source in the shortcut menu.
- Make your desired changes between the CASE funtionname and ENDCASE keywords.
Tip: You can add Maintain Data language code to your function using the Language Wizard. Place your insertion point where you want your code to go, right-click in the Maintain Data Editor window and select Language Wizard in the shortcut menu.
Edit the Name, Arguments, Return Value, and Description of a Function
- Procedure
- Right-click the function in the Requests & Data Sources panel.
- Click Edit in the shortcut menu.
- Make your changes in the Edit Function dialog box and click OK.
Function Editor: Signature Tab

This dialog box contains the following options:
The name you assign to your function (or case). This name can be up to 66 characters long. It must begin with a letter and can include any combination of letters, digits, and underscores (_).
Lists the arguments that the function requires. When you invoke the function, you pass to it variable names or values to substitute for these arguments.
- To create a new argument, double-click the gray rectangle or click the plus sign to the right of the field.
- To edit an existing argument, double-click its name.
- To change the order of the arguments, select the argument to be moved and use the arrows to move it up or down.
- To delete an argument, select it and click the red X to the right of the field.
Contains the name and data type of the return value that the function calculates. This information can be entered directly in the field, or you can use the ellipsis button to open the Function Return dialog box to enter it.