NexusFi: Find Your Edge


Home Menu

 





PowerLanguage/EasyLanguage. Trying to use a Function as a "Library" in a scalable way


Discussion in EasyLanguage Programming

Updated
    1. trending_up 397 views
    2. thumb_up 0 thanks given
    3. group 1 followers
    1. forum 0 posts
    2. attach_file 0 attachments




 
Search this Thread

PowerLanguage/EasyLanguage. Trying to use a Function as a "Library" in a scalable way

(login for full post details)
  #1 (permalink)
stedia
Santiago, Santiago
 
Posts: 1 since Nov 2023
Thanks Given: 0
Thanks Received: 0

Hello everyone!

Sometimes I use a PowerLanguage/EasyLanguage function as if it were a kind of "library", i.e. with multiple possible outputs based on the called section. This, knowing that a function and a library are different concepts, but in fact trying to use what provides PowerLanguage/EasyLanguage to obtain an equivalent result.

An ideal solution would be to be able to call only a specific code section from the function in a simplified way, in order to obtain the result value from that specific called section.

Ok, when talking about letís say 2-5 possible outputs, then a suitable solution is to use a "multiple-output" function, but I can see this is not scalable in a practical way because for a larger number of possible outputs like 20, 50, or more, then the required size for the calling instruction would be unnecessarily long, so it happens that the calling instructions would have an impractical handling and this would not be a suitable solution when talking about many possible outputs, because just imagine to have to write instructions that contain letís say 80 possible outputs, having to specify 0s (or whatever) in 79 places and then one real value in the specific correct "index", doing this each time you need to call the function.


Well, in a C-family language (C++, C#), a solution would be to simply call a public method (the specific required section) from a library file just specifying the method name with the arguments passed to it, which is direct and simplified to handle either if the library has 2 public methods or if it has 50 public methods, because in the calling instruction it is necessary to only specify about the method needed and it is not necessary to specify anything about the other methods in the library.

So the question is, how would be possible to have in PowerLanguage/EasyLanguage something similar or as equivalent as possible, as you could have in C# or others, with a simplified calling instruction and having everything in 1 single file?



Possible studied and discarded solutions for now:

- Placing each function section in separated and single function files.
In this case is not a solution because the purpose is to have related elements into 1 single place (in the same place), and not in 50-80 different files here and there per each situacion.

- Using a switch/case specifying an int number for each the possible case (each possible called section).
The problem with a possible solution like this is that a number doesnít give any kind of hint by itself about what is the content of the case in the switch, so when you have many functions and each of them with multiple possible values, then you wonít remember what is the case `8`, or the case `41`, etc.

- Using a switch/case specifying a string name for each the possible case (each possible called section).
The problem with a possible solution like this is that the string for each case (section name) wonít be accessible from other scripts, so it would require to manually type the string name of each section, that is something that can causes typing errors. This would be very valid solution if each string constant name from each case were accessible from the calling script and that when you are typing the function name, then that the Editor shows a list with the possible cases string values where you just need to select one from the given list and done.


I want to know about how other programmers handle situations like this.


Thank you

Reply With Quote





Last Updated on November 1, 2023


© 2023 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts