Visual FoxPro is, I'm guessing, an interpreted language. Thus, using the mechanism you describe, you can pass a string to the interpreter, and ask it to find the function of that name and execute it.
Delphi is, of course, compiled. At compile time, the string names of functions have already been removed; so in Delphi we instead use function pointers. A common example of this in Delphi is the Compare used in various Sorts. Here's what Help on TList,Sort says:
Code:
type TListSortCompare = function (Item1, Item2: Pointer): Integer;
procedure Sort(Compare: TListSortCompare);
Description
Call Sort to sort the items in the Items array. Compare is a comparison function that indicates how the items are to be ordered.
So you write a Compare function of your own, depending on how objects in your particular list should be compared, and when you want to sort the list, you say:
Code:
mylist.Sort(mycomparefunction);
In the more general case, you'll want to declare a type that describes the sort of functions/procedures you want to call, with their parameter lists and all, like:
Code:
type TMyFunction = function (myparameterlist): myreturntype;
, and then you can do with it all the things that you can usually do with a type: create variables of that type, pass objects of that type as function parameters, return objects of that type as function results, etc.
So you might say:
Code:
function myfunction1(myparameterlist): myreturntype;
begin
Result := '1';
end;
function myfunction2(myparameterlist): myreturntype;
begin
Result := '1';
end;
, then later:
Code:
var myfunctionvariable: TMyFunction;
begin
myfunctionvariable := myfunction1;
myfunctionvariable(myparamterlist);
end;
More help is available in help under under "Procedural types".
-- Doug Burbidge mailto:dougburbidge@yahoo.com