Define class or pass a function by reference?

Is it possible, in script, to either define a class hierarchy or to pass a reference to a function or procedure as a parameter to another function or procedure?

Thanks in advance for your insight.


Hi Cameron,

I do not know if I got you correctly, but how about

// Called when RuntimeData (global variables shared among scripts) change.
// Set data with SetRuntimData(key, value);
procedure OnRuntimeDataChange(Key, Value: string);

Would that work for you?

Runtime regards


Thank you for the suggestions. It seems I failed to convey my meaning. :slight_smile: I already use the technique you suggested to solve a different problem.

An example of what I was asking might loosely be expressed:

procedure workerA;
procedure workerB;

procedure doWork(worker : procedure_reference);
  while some_condition do

// (Later I added that) this would be called along the lines of:

This might be characterised as a procdural implementation of the visitor pattern.

I managed to solve my problem by putting the “worker” in a separate file from the one that will call it. I can therefore have multiple task-specific workers all with the same name.