PROCEDURE

From Lianjapedia
Jump to: navigation, search

Purpose

Declare a procedure

Syntax

PROCEDURE <procedure name>

See Also

DO, ENDPROC, FUNCTION, FUNCTION_EXISTS(), PARAMETERS, PRIVATE, PUBLIC, RETURN, SET PROCEDURE, VARINFO()

Description

The PROCEDURE statement marks the beginning of a procedure. A procedure declaration is terminated with a RETURN statement. You may have other RETURN statements within the procedure body, provided that they are properly nested between IF...ENDIF, DO WHILE ...ENDDO, or DO CASE ...ENDCASE. Procedure names must be unique within the first 32 characters. They must begin with a letter or underscore, followed by any combination of letters (A-Z), digits (0-9), and underscores (_), and may not contain any blanks or spaces.

You can include procedures in your program files, as well as in procedure library files. If a procedure is included in a program file, then it must be defined before it is used. For example, if you issue a command DO MAIN, then the command PROCEDURE MAIN must be on a line before the line containing the DO MAIN statement. You make all the procedures in a procedure library file known to the Lianja/4GL by using the SET PROCEDURE TO command.

To execute a procedure, you just issue a DO <procedure name> command, as if you were calling a program file, or you can use the procedure as a user defined function (UDF) and pass parameters to it as with any standard Lianja function. The limit to the number of parameters that you can pass is 40.

Note that procedures can be called using a DO statement such as: do procname with para1, para2, para3or they can be called as functions without assigning a return value, as in: procname(para1,para2,para3)

There is no limit to the number of procedures that can be declared in the Lianja/4GL.

Example

// File: finance.prg
procedure payment2
  parameters pmt
return pmt
 
procedure future
  ...
return