1
0
Fork 0

Add procedural type example

This commit is contained in:
Timothy Warren 2021-10-05 14:35:24 -04:00
parent 06d0b981b7
commit 1c31e8b8c4
1 changed files with 24 additions and 0 deletions

View File

@ -0,0 +1,24 @@
program procedural_type;
{$mode objfpc}{$H+}
// Interface for an event handler
// This is a 'procedural type'
type TOneStringParamProc = procedure(aString: string);
var stringProc: TOneStringParamProc = nil;
// A possible implementation
procedure ShowStr(s: string);
begin
WriteLn('The string passed to this procedure is ', s);
end;
begin
// Use the event handler
stringProc := @ShowStr;
stringProc('"string parameter"');
{$IFDEF WINDOWS}
ReadLn;
{$ENDIF}
end.