A few options:

1.  Use an IDispatch interface - this uses named / numbered methods.

2.  If the methods are published, see TReader.FindMethod for information on
how to get the method address.

3.  (This is my preferred way.)  Do away with naming methods.  Instead
create a base class:

TSomeBaseClass = class (TPersistent)
public
  class procedure SomeMethod (Params: Integer); virtual; abstract;
end;

and for each "method" you create a class, as in:

TMethod1 = class (TSomeBaseClass)
public
  class procedure SomeMethod (Params: Integer); Override;
end;


Then register your classes:

RegisterClassAlias ([TMethod1, 'Name1']);
RegisterClassAlias ([TMethod2, 'Name2']);

and when you need to call your method:

TSomeBaseClass (GetClass ('Name1')).SomeMethod (123);


Regards,
Dennis.

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
Behalf Of Steven Wild
Sent: Thursday, 9 March 2000 17:26
To: Multiple recipients of list delphi
Subject: [DUG]: Accessing methods



We have a situation where we want to run a method.  The method name is valid
and is of a known structural signature.  However the name of the method is
stored in a string variable.  There are several methods available with the
same structural signature.  Any one of them could be in the variable.

In this circumstance it is inappropriate to use an if else if else if .....
type structure.

We have experience defining a procedural type and then latter assigning a
method returned as a string from a DLL to it as in
       @OpenForm := GetProcAddress(dllHandle, pchar(Proc));
       OpenForm(Application, MainForm);

How do we do the same thing when we aren't using dlls and therefore don't
have a DLL handle to include in the call to GetProcAddress or the like?

Steven

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to