FUNCTION

FUNCTION statement indicates the beginning of the FUNCTION program block. The FUNCTION program block has this structure:

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:

FUNCTION my_function (p_lname, p_fname)

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.

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:

 

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. 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

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.

 

Contact Us

Privacy Policy

Copyright © 2024 Querix, (UK) Ltd.