Pass into a procedure

Completed

When you create procedures or use existing procedures, parameters are important. You can use a parameter to pass information to a procedure. Procedures could include the following parameters:

  • Values, references, or expressions are sent to the procedure

  • Information is provided to the procedure

  • The function can change the information

When you're calling procedures from within your code, Visual Studio Code helps you by providing information about the parameters that the procedure requires. When you start typing, IntelliSense of Visual Studio Code shows you the parameters with extra information on how to use them. If a parameter is surrounded by square brackets, it's indicating that the parameter is optional.

Example of IntelliSense in Visual Studio Code.

To define a procedure with parameters, you need to separate all parameters with a semicolon in the procedure definition.

procedure MyFunction(Param1: Integer; Param2: Text[50])

Exit statement

When you create a procedure, and the procedure has finished running its code, if you want your procedure to return something, you can use the exit statement.

exit(<expression>);

exit(param * param);

If you don't provide a return value in the exit statement, your procedure ends. This feature can be useful if you want your procedure to stop after a certain condition. Otherwise, you can provide a value that can be returned.

local procedure MyFunction() : Integer
var 
   myResult: Integer
begin
   myResult := Power(2, 3);
   exit(myResult);
end;