[fpc-pascal] how to pass a procedure address and execute it?

waldo kitty wkitty42 at windstream.net
Thu Jan 23 20:18:38 CET 2014


i'm trying to use one routine (centralControl) to process data from two 
different routines (inputThis and outputThat)... the one routine 
(centralControl) needs to call one of two other routines (doThis or doThat)... 
how? :(


procedure doThis;
begin
end;

procedure doThat;
begin
end;

procedure centralControl(var aValue : word; theRecord : somerec; var whichProc);
begin
   case aValue of
     0 : begin
           whichProc;   <<-- compiler says "illegal expression"
         end;
     1 : begin
           if theRecord^.aValue = something then
             whichProc;
         end;
end;

procedure inputThis;
begin
   centralControl(foo,thisRecord, at doThis);
end;

procedure outputThat;
begin
   centralControl(foo,thisRecord, at 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