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

Marco van de Voort marcov at stack.nl
Thu Jan 23 20:27:15 CET 2014


In our previous episode, waldo kitty said:
> 
> 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

whichproc is typeless and thus roughly equal to a pointer to a
byte (though semantically different, and add another pointer indirection for
the VAR). So the compiler doesn't know what to do with it.

> how? :(

Define a procedure type that matches both procedures, in your example

Type
  TProc = procedure ; // which is predefined in system afaik.

and change whichproc to that type. The VAR is not necessary in this case.
  



More information about the fpc-pascal mailing list