[fpc-pascal] Calling a function by name (as string) read from a text file

Jilani Khaldi jilani at cheapnet.it
Wed Oct 10 14:33:09 CEST 2007

> type  Tsetupfunc_mapping=record
>         name:string;
>         func:setupfunc;
>       end;
> const setupfunc_mapping:array[0..2] of Tsetupfunc_mapping=(
>        (name:'setup_function_1';func:@setup_function_1),
>        (name:'setup_function_2';func:@setup_function_2),
>        (name:'setup_function_3';func:@setup_function_3));
> Then search the name of the function you want to call in the table, then 
> call the function in the "func" field.
Thanks, but the consts should be:
const setupfunc_mapping: array[0..2] of Tsetupfunc_mapping=(
         (name: 'setup_function_1'; func: setup_function_1),
         (name: 'setup_function_2'; func: setup_function_2),
         (name: 'setup_function_3'; func: setup_function_3));

However compiling with {$mode objfpc} I get the error:
** Error: Some fields coming before "name" weren't initialized
and it dosen't compile.
While with {$mode delphi} it compiles but with a simple warning:
** Warning: Some fields coming before "name" weren't initialized
The question now is how to get it compiling (and executing) without 
error using {$mode objfpc}?

the code compiles and runs without warnings using Delphi.


More information about the fpc-pascal mailing list