25 lines
473 B
ObjectPascal
25 lines
473 B
ObjectPascal
|
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.
|