Top > Lycia reference > Querix 4GL > Statements > FUNCTION
To meet your needs, we constantly work to improve Querix products.
This means that Lycia documentation is developing as well.
In case you have found a certain dissonance between the provided information and the actual behavior of Lycia 3 and/or your applications, please, let us know about this via documentation@querix.com so that we can introduce the necessary changes to our documentation.
Thank you for your attention and cooperation.
FUNCTION statement indicates the beginning of the FUNCTION program block. The FUNCTION program block has the following structure:
Element |
Description |
Function Name |
The name that you declare for this 4GL function. |
Argument List |
A list of zero or more formal arguments of the function separated by commas |
RETURNS clause |
An optional clause used to make the function compliant with the web services |
Function Body |
Executable statements that function contains |
RETURN Clause |
Optional clause that returns values from the function into the calling routine |
The FUNCTION program block is a set of statements that has a unique name. The name of a function must be unique within one application. This means that no other function and no report can have the same name. It cannot also be the same as the name of a built-in 4GL function. The name of the function is not case sensitive.
Formal arguments of a function are the identifiers enclosed in parentheses that follow the function name. They will be transferred to the function, when it starts executing; they are referenced by value and must match the formal arguments in the CALL statement in order, number, they must be of compatible data types. The names of the arguments must be unique within the function. They are local to the function and cannot be referenced outside of it.
FUNCTION my_function (p_lname, p_fname)
If a function requires no formal arguments, there still must be an empty argument list enclosed in parentheses: function()
The FUNCTION program block can be called from any part of the source code in any module within one program.
The FUNCTION statement:
declares the name of the function and its formal arguments
defines the FUNCTION program block
The FUNCTION block is a separate program block like the MAIN or REPORT program blocks, therefore it cannot occur within another program block, e.g. it cannot be a part of the MAIN program block. It cannot also appear within another FUNCTION block.
A FUNCTION block is the program block delimited with the help of the FUNCTION keyword at the beginning and END FUNCTION keywords at the end.
If a function returns a single value, it can be invoked within a 4GL expression as its operand (see the "Functions used as Operands in 4GL Expressions" section for more details). If a function returns more than one value, it must be called with the help of the CALL statement. If a function returns some values, it should contain the RETURN clause and the calling routine should have the RECEIVING clause. The variables in the RETURN clause of a FUNCTION must match the variables in the RETURNING clause of the CALL statement in order, number and data types.
END FUNCTION keywords indicate the end of the FUNCTION program block. They can be followed by another FUNCTION program block or a REPORT program block.