PROCEDURE Command
Creates a user-defined procedure in a program file. There are two versions of the syntax.
PROCEDURE ProcedureName [ LPARAMETERS parameter1 [ ,parameter2 ] ,... ] Commands [ RETURN [ eExpression ] ] [ENDPROC] |
PROCEDURE ProcedureName( [ parameter1 [ AS para1type ][ ,parameter2 [AS para2type ] ] ,...] ) [ AS returntype ] Commands [ RETURN [ eExpression ] ] [ENDPROC] |
Parameters
- PROCEDURE ProcedureName
-
Designates the beginning of a user-defined procedure and specifies the name of the procedure. ProcedureName must begin with a letter or underscore and can contain up to 254 characters with any combination of letters, numbers, and underscores.
- [ LPARAMETERS parameter1 [ , parameter2] ,... ] ]
-
Assigns data from the calling program to local variables or arrays. You can also use the PARAMETERS keyword instead of LPARAMETERS to accept privately scoped parameters. You can pass a maximum of 26 parameters to a procedure.
For more information, see LPARAMETERS Command and PARAMETERS Command.
- ( [ parameter1[ AS para1type][ , parameter2[ AS para2type] ],...] )
-
Assigns data from the calling program to local variables or arrays. You can use the AS para1type clause to specify the data type of the variable.
Note Including the parameters inside parentheses (()) immediately following the procedure name indicates that the parameters are locally scoped to the procedure.
- [ AS returntype]
-
Specifies the data type of the return value.
You can use the AS clause to implement strong typing. For more information, see How to: Implement Strong Typing for Class, Object, and Variable Code.
- Commands
-
Specifies the Visual FoxPro commands to execute when executing the function.
- [ RETURN [ eExpression] ]
-
Returns control to the calling program or to another program. eExpression can specify a return value.
Note You can include the RETURN command anywhere in the procedure to return control to the calling program or to another program and to define a value returned by the procedure. If you do not include the RETURN command, Visual FoxPro executes an implicit RETURN automatically when the procedure quits. If the RETURN command does not include a return value or if an implicit RETURN is executed, Visual FoxPro assigns True (.T.) as the return value. For more information, see RETURN Command.
- [ ENDPROC ]
-
Indicates the end of the PROCEDURE structure.
Note The ENDPROC keyword is optional because the function quits when it encounters another PROCEDURE command, a FUNCTION command, or the end of the program file.You cannot include normal executable program code following user-defined procedures in a program file. Only other user-defined procedures, functions, and class definitions can follow the first PROCEDURE or FUNCTION command in the file.
Remarks
Example
See Also
© , 1996-2020 • Updated: 11/10/20
Comment or report problem with topic
Microsoft Visual FoxPro 9 SP2 Help file, VFPX Edition v1.08