Call a non class function with RTTI

This is the forum for miscellaneous technical/programming questions.

Moderator: 2ffat

Call a non class function with RTTI

Postby Ahmed Sayed » Wed Feb 20, 2019 8:58 am

Hi, is it possible to call a unit function not a function that belongs to a class from rtti?
In TRttiMethod.Invoke I have to set the instance parameter is there another mechanism that can allow me to invoke functions like: Today, Now, Date, ReplaceStr, SplitString but with rtti or by their name?

Any help will be appreciated
Thanks in advance
Ahmed Sayed
Top Poster
Top Poster
 
Posts: 28
Joined: Thu Nov 08, 2018 4:12 pm

Re: Call a non class function with RTTI

Postby rlebeau » Wed Apr 17, 2019 12:06 pm

Ahmed Sayed wrote:Hi, is it possible to call a unit function not a function that belongs to a class from rtti?


No. RTTI is tied to types, not units. The second T in RTTI stands for "Type", afterall.

Ahmed Sayed wrote:is there another mechanism that can allow me to invoke functions like: Today, Now, Date, ReplaceStr, SplitString but with rtti or by their name?


No. Why do you need this? You could instead use a TDictionary holding names mapped to function pointers.
Remy Lebeau (TeamB)
Lebeau Software
User avatar
rlebeau
BCBJ Author
BCBJ Author
 
Posts: 1610
Joined: Wed Jun 01, 2005 3:21 am
Location: California, USA


Return to Technical

Who is online

Users browsing this forum: Google [Bot] and 17 guests

cron