 
    
            Pieces of long code to be stored in a script or library
            
                 07 Dec 2018, 04:19
            
                    
Dear Panagiotis,
in many of my bots I have the same pieces of long code.
There is a way to store it in a script or library and recall it back in a cBot with a simple line of code instead of hundreds line of code ?
Thank you very much for your always kind help
Replies
                     mparama
                     07 Dec 2018, 18:33
                                            ( Updated at: 21 Dec 2023, 09:21 )
                                    
RE:
Panagiotis Charalampous said:
Hi Luigi,
A cBot is nothing less than a C# project. So if you edit it using Visual Studio you can have all the options available for a C# project. This means that you can have separate classes for reusable code. See below an example of calling a function of another class inside the cBot.
This way you can organize your code in a proper object oriented approach. Let me know if you need any additional assistance.
Best Regards,
Panagiotis
Thank youv very much !!!!
@mparama
                     ctid581738
                     10 Jun 2023, 17:40
                                            ( Updated at: 21 Dec 2023, 09:23 )
                                    
Hi Panagiotis! It seems, each Indicator and Bot uses its own project. So, how is it possible to share code between projects (Indicators or Bots)?
PanagiotisCharalampous said:
Hi Luigi,
A cBot is nothing less than a C# project. So if you edit it using Visual Studio you can have all the options available for a C# project. This means that you can have separate classes for reusable code. See below an example of calling a function of another class inside the cBot.
This way you can organize your code in a proper object oriented approach. Let me know if you need any additional assistance.
Best Regards,
Panagiotis
@ctid581738
                     PanagiotisChar
                     12 Jun 2023, 09:35
                                    
Hi there,
You need to add a project reference.
Need help? Join us on Telegram
Need premium support? Trade with us
@PanagiotisChar


PanagiotisCharalampous
07 Dec 2018, 10:23 ( Updated at: 21 Dec 2023, 09:21 )
Hi Luigi,
A cBot is nothing less than a C# project. So if you edit it using Visual Studio you can have all the options available for a C# project. This means that you can have separate classes for reusable code. See below an example of calling a function of another class inside the cBot.
This way you can organize your code in a proper object oriented approach. Let me know if you need any additional assistance.
Best Regards,
Panagiotis
@PanagiotisCharalampous