[fpc-pascal] how to pass a procedure address and execute it?
waldo kitty
wkitty42 at windstream.net
Fri Jan 24 21:20:45 CET 2014
On 1/23/2014 2:18 PM, waldo kitty wrote:
following up on this, how do i pass parameters to doThis and doThat?? do i have
to use an intermediate pre_doThis and pre_doThat which handles the calls from
centralControl and then calls doThis and doThat with the necessary parameters?
type
TProc = Procedure;
procedure doThis(aRecord : somerec;);
begin
addRecord(aRecord);
end;
procedure doThat(outFile : textfile; aRecord : somerec;);
begin
writefile(outFile,aRecord);
end;
procedure pre_doThis;
begin
doThis(theRecord);
end;
procedure pre_doThat;
begin
doThat(oFile,theRecord);
end;
procedure centralControl(var aValue : word; theRecord : somerec; whichProc : TProc);
begin
case aValue of
0 : begin
whichProc;
end;
1 : begin
if theRecord^.aValue = something then
whichProc;
end;
end;
procedure inputThis;
begin
centralControl(foo,thisRecord, at pre_doThis);
end;
procedure outputThat;
begin
centralControl(foo,thisRecord, at pre_doThat);
end;
--
NOTE: No off-list assistance is given without prior approval.
Please keep mailing list traffic on the list unless
private contact is specifically requested and granted.
More information about the fpc-pascal
mailing list