CallByName
Hello there,
in VB there is a function called CallByName which you
can simply pass the name of an object the method to be
called and the parameters to be passed is there anything
simular in Delphi.(Before I write my own).
Thank you.
It can certainly be done, but it is not as simple as it first seems. Firstly, not all objects have a Name property. They must descend from TComponent to get the Name property or specify a Name property for each object.
Secondly, this would be a real time killer in an application, especially if it was called inside a tight loop. This is why:
Steve ''Sly'' Williams Code Monkey Krome Studios
Secondly, this would be a real time killer in an application, especially if it was called inside a tight loop. This is why:
- Iterate through all known objects
- retrieving the RTTI for the object
- iterating through published properties to find the Name property
- doing a string compare with the Name property
- Iterate through all public methods of the object doing a string compare until the given method name is found.
- Call the method.
Steve ''Sly'' Williams Code Monkey Krome Studios
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement