Page 1 of 1

Call a non class function with RTTI

PostPosted: Wed Feb 20, 2019 8:58 am
by Ahmed Sayed
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

Re: Call a non class function with RTTI

PostPosted: Wed Apr 17, 2019 12:06 pm
by rlebeau
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.