Skip to content

Procedure Parameters ​

A Procedure is a sub-routine that does not return a value. Any results obtained from the execution of a Procedure are either contained in one or more output arguments, or have another purpose such as writing something to the screen or writing to a file.

In this simple example of a Procedure called FindTheName, the parameter is TheDetails.

pascal
procedure FindTheName(TheDetsils : string);

Or this more In this example of a Procedure called FindTheName, the parameter is TheDetails.

pascal
procedure WhatTime(dateTime : TDateTime);
 begin
 //Display the date and time passed to the routine
  LogInfo('Date and time is '+DateTimeToStr(dateTime));
 end;

If a Procedure accepts multiple parameters they should be separated with commas such as in the following example.

pascal
procedure ShowSum(a, b : integer);
var
  total : integer;
begin
 //Add the two numbers together
  total := a + b;
 //And display the sum
  LogInfo('%d + %d = %d',[a,b,total]);
end;

A combination of keywords can be used in a Procedure - for instance as the following shows, you can use the const and out keywords in the one Procedure. And this Procedure called CopyStr can then itself be called in the following Procedure.

pascal
procedure CopyStr(const AStr : String; out AOutStr : String);
begin
  AOutStr := AStr;
end;

procedure ScriptEvent (var Value : variant);
var
  SomeStr, WhatStr: String;
begin
  SomeStr := 'Hello World';
  CopyStr(SomeStr, WhatStr);
  LogInfo(WhatStr);
end;