Harbour (software) - Syntax and Semantics - Procedures/Functions

Procedures/Functions

PROCEDURE SomeProcedureName PROCEDURE SomeProcedureName PROCEDURE SomeProcedureName( Param1' ) INIT PROCEDURE SomeProcedureName EXIT PROCEDURE SomeProcedureName FUNCTION SomeProcedureName FUNCTION SomeProcedureName FUNCTION SomeProcedureName( Param1' )

Procedures/Functions in Harbour can be specified with the keywords PROCEDURE, or FUNCTION. Naming rules are same as those for Variables (up to 63 characters non case sensitive). Both Procedures and Functions may be qualified by the scope qualifier STATIC to restrict their usage to the scope of the module where defined.

The INIT or EXIT optional qualifiers, will flag the procedure to be automatically invoked just before calling the application startup procedure, or just after quitting the application, respectively. Parameters passed to a procedure/function appear in the subroutine as local variables, and may accept any type, including references.

Changes to argument variables are not reflected in respective variables passed by the calling procedure/function/method unless explicitly passed BY REFERENCE using the @ prefix.

PROCEDURE have no return value, and if used in an Expression context will produce a NIL value.

FUNCTION may return any type by means of the RETURN statement, anywhere in the body of its definition.

An example procedure definition and a function call follows:

x := Cube( 2 ) FUNCTION Cube( n ) RETURN n ** 3

Read more about this topic:  Harbour (software), Syntax and Semantics

Famous quotes containing the words procedures and/or functions:

    Young children learn in a different manner from that of older children and adults, yet we can teach them many things if we adapt our materials and mode of instruction to their level of ability. But we miseducate young children when we assume that their learning abilities are comparable to those of older children and that they can be taught with materials and with the same instructional procedures appropriate to school-age children.
    David Elkind (20th century)

    Those things which now most engage the attention of men, as politics and the daily routine, are, it is true, vital functions of human society, but should be unconsciously performed, like the corresponding functions of the physical body.
    Henry David Thoreau (1817–1862)