Difference between revisions of "PROCEDURE"

From Lianjapedia
Jump to: navigation, search
 
(4 intermediate revisions by 3 users not shown)
Line 6: Line 6:
  
 
==See Also==
 
==See Also==
[[DO]], [[ENDPROC]], [[FUNCTION]], [[FUNCTION_EXISTS()]], [[LINK]], [[PARAMETERS]], [[PRIVATE]], [[PUBLIC]], [[RETURN]], [[SET PROCEDURE]], [[VARINFO()]]
+
[[DO]], [[ENDPROC]], [[FUNCTION]], [[FUNCTION_EXISTS()]], [[PARAMETERS]], [[PRIVATE]], [[PUBLIC]], [[RETURN]], [[SET PROCEDURE]], [[VARINFO()]]
  
 
==Description==
 
==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.
 
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 Recital/4GL by using the SET PROCEDURE TO command.
+
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 Recital function.  The limit to the number of parameters that you can pass is 40.
+
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:
 
Note that procedures can be called using a DO statement such as:
Line 19: Line 19:
 
procname(para1,para2,para3)
 
procname(para1,para2,para3)
  
There is no limit to the number of procedures that can be declared in the Recital/4GL.  The commands LIST | DISPLAY PROCEDURE will list all currently active functions and procedures.
+
There is no limit to the number of procedures that can be declared in the Lianja/4GL.
 
+
If SET COMPATIBLE is set to VFP, the PROCEDURE declaration can be terminated with an ENDPROC command rather than a RETURN.  It will also be terminated when another PROCEDURE or FUNCTION command is reached.
+
 
+
If a procedure library contains a procedure with the same name as the containing library, a call to that name will run the procedure if SET COMPATIBLE is set to VFP or FOXPRO.
+
  
 
==Example==
 
==Example==
Line 39: Line 35:
 
[[Category:Documentation]]
 
[[Category:Documentation]]
 
[[Category:Commands]]
 
[[Category:Commands]]
[[Category:Applications]]
+
[[Category:User Defined Functions]]
[[Category:Applications Commands]]
+

Latest revision as of 07:54, 4 February 2013

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