RTC Forums
May 08, 2024, 08:54:18 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: How to add many of RtcFunctions to RtcFuntionGroup  (Read 3993 times)
xdu2050
RTC Expired
*
Posts: 7


« on: April 21, 2017, 10:21:02 AM »

I want to  add many of  TRtcFunction to TRtcFunctionGroup, or TRtcFunctionGroup load a script file, compile as a global method.

Can add this procedure?
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #1 on: April 21, 2017, 10:32:00 AM »

You can add as many "TRtcFunction" components to a single "TRtcFunctionGroup" component as you want. Simply assign the "TRtcFunctionGroup" instance to the "Group" property of each "TRtcFunction" component. You can do this in code (it is a simple assignment) or in the Delphi IDE at design-time.

MyFunction1.Group := MyFunctionGroup;
MyFunction2.Group := MyFunctionGroup;
MyFunction3.Group := MyFunctionGroup;

And ... by assigning the same "TRtcFunctionGroup" instance to the "FunctionGroup" property of any number of "TRtcServerModule", "TRtcClientModule" and/or "TRtcScriptEngine" components, you can make all TRtcFunctions assigned to that "TRtcFunctionGroup" component accessible from all these components.

MyServerModule.FunctionGroup := MyFunctionGroup;
MyScriptEngine.FunctionGroup := MyFunctionGroup;
MyClientModule.FunctionGroup := MyFunctionGroup;

You can also assign a "Parent" Group to your "FunctionGroup", to make all Functions assigned to your "FunctionGroup" assessible from the "Parent" Function Group. The same works in the other direction as well, by using the "HelperGroup" property, giving your "FunctionGroup" access to all Functions assigned to the "HelperGroup".

The only thing you can NOT do, is to use a single "TRtcFunction" component with multiple "TRtcFunctionGroup" components. But since any Function Group can use its "Parent" property to give access to its functions to another Function Group, and any Function Group can use its HelperGroup property to gain access to functions from another Function Group, there is really no need for that.

Best Regards,
Danijel Tkalcec
Logged
xdu2050
RTC Expired
*
Posts: 7


« Reply #2 on: April 21, 2017, 03:04:02 PM »

Of course, we can do this, but I want to add lot's of logic code like rtcScript in QuickStart , then add TRtcFunction will be a very troublesome thing, if TRtcFunctionGroup can directly load the script file, this will be perfect.
Code:
<?
function $fun1
begin
   ......
end;

function $fun2
begin
   ......
end;

function $fun3
begin
   ......
end;
?>
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #3 on: April 21, 2017, 03:55:56 PM »

Functions written in a Script file are NOT the same as functions written in Delphi and assigned to a TRtcFunction component. Scripted functions are interpreted using the Scripting Engine, while functions written in Delphi and assigned to a TRtcFunction component are compiled into native executable code. These are two entirely different things.

If I understand you correctly now, you would like to write functions in a Script file and make your scripted functions accessible through a "TRtcFunctionGroup" component, just like you can access functions written in Delphi using the TRtcFunction component. Is that what you mean?

Best Regards,
Danijel Tkalcec
Logged
xdu2050
RTC Expired
*
Posts: 7


« Reply #4 on: April 25, 2017, 10:41:22 AM »

Thx
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.023 seconds with 15 queries.