XHarbour - 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 xHarbour 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:  XHarbour

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)

    Mark the babe
    Not long accustomed to this breathing world;
    One that hath barely learned to shape a smile,
    Though yet irrational of soul, to grasp
    With tiny finger—to let fall a tear;
    And, as the heavy cloud of sleep dissolves,
    To stretch his limbs, bemocking, as might seem,
    The outward functions of intelligent man.
    William Wordsworth (1770–1850)