8
I'd like to use procedure of object in a record, like so:
TCommandRec = record
name: string;
fn: procedure of object;
end;
I can create an array with this by assignment:
commands: array [0..1] of TCommandRec;
...
commands[0].name := '-help';
commands[0].fn := DoHelp;
commands[1].name := '-load';
commands[1].fn := DoLoad;
What I'd really like to do is declare a constant:
const
cmds: array [0..1] of TCommandRec =
(
(name: '-help'; fn: DoHelp),
(name: '-load'; fn: DoLoad)
);
However, I get errors for DoHelp and DoLoad - Constant expression expected. These are two methods of a class. Is there some syntax I need to use to make this work or am I stuck building the array at runtime?