Create a Function with the Application Generator

Top  Previous  Next

To create a function with the Application Generator, you must specify both a Prototype and a Return Value in the Procedure Properties dialog. The prototype must specify at least a datatype for the return value. You must specify a prototype before you can specify a return value.


In the Prototype field in the Procedure Properties dialog, type the following prototype:


This specifies no parameters and a return datatype of LONG. The datatype may be any valid Clarion language datatype.


Press the Actions button to open the Procedure Properties sub-dialog.

This enables the Return Value field.


In the Return Value field, press the ellipsis button (...) to select or define a variable to receive the return value for your function.

You should embed code to assign the appropriate value to the returned variable.

Receiving Return Values from Procedures

Although you may call a function with Call a Procedure from the Actions dialog from a button or method, this method does not allow you to receive return values. Therefore, you should generally use embedded source or hand code to receive a return value from a function. Following is one way to call a function from a control; however, you may call a function in many ways.


Right-click on the button control, and select the Embeds option.


In the Embedded Source dialog, choose the Accepted embed point for Control Event Handling, after generated code, then press Insert.


In the Select Embed Type dialog, select SOURCE.


In the Text Editor, type your function call, for example:

       ValueFromFunction = MyFunction()

where ValueFromFunction is a local, module, or global variable that receives the value returned by the function.


Press the Save and Close button from the menu, then save your embedded source when prompted.