Dynamic Arrays, Functions, Lists

Questions about MultiCharts and user contributed studies.
TraderWalrus
Posts: 63
Joined: 13 Sep 2016

Dynamic Arrays, Functions, Lists

Postby TraderWalrus » 20 Mar 2017

I want a function to return an array with an initially unknown size. As far as I understood, the only way to pass an array, by reference, to a function, is using the following syntax:

inputs: arrName[MAXSIZE](NumericArrayRef);
variables: MAXSIZE(100);

Does it mean that array_setmaxindex can't be used inside the function, and that only static arrays can be passed by reference? This seems like a big waste of memory to create large arrays that are required only in some cases and not in others plus it complicates the code.

I also considered using Lists. I downloaded the ELCollections DLL to the correct folder but statements such "ListID = ListN.New; " indicate it isn't recognized. Another question - what is the scope of those lists? can a function access a list? I don't see how can a list be passed to a function..

User avatar
ABC
Posts: 626
Joined: 16 Dec 2006
Contact:

Re: Dynamic Arrays, Functions, Lists

Postby ABC » 20 Mar 2017

I also considered using Lists. I downloaded the ELCollections DLL to the correct folder but statements such "ListID = ListN.New; " indicate it isn't recognized. Another question - what is the scope of those lists? can a function access a list? I don't see how can a list be passed to a function..
TraderWalrus,

this sounds like you didn't import the corresponding ELD file with the required functions. You should be able to find it here on the forum. The original ELC disctribution also contains a manual which explains everything you need to know to get you going. In your case you'd pass the list ID to the function in case you want to use it there.

Regards,

ABC

TraderWalrus
Posts: 63
Joined: 13 Sep 2016

Re: Dynamic Arrays, Functions, Lists

Postby TraderWalrus » 20 Mar 2017

I went through the detailed .doc manual, it doesn't mention what needs to be imported. Or perhaps you refer to another guide - specific information with links will be greatly appreciated.

User avatar
ABC
Posts: 626
Joined: 16 Dec 2006
Contact:

Re: Dynamic Arrays, Functions, Lists

Postby ABC » 20 Mar 2017

If you got the doc from the original zip file, it also contains the functions ELD that you'll have to import before you can use the DLL. You can probably find them here, although I didn't check it: viewtopic.php?=&p=8189

Regards,

ABC

TraderWalrus
Posts: 63
Joined: 13 Sep 2016

Re: Dynamic Arrays, Functions, Lists

Postby TraderWalrus » 20 Mar 2017

Ok, ELD file imported and it's being recognized and compiled. Any insights about the other points? I find myself spending hours on things that need to be trivial, managing simple data structures. Is life better with MC.NET?

User avatar
ABC
Posts: 626
Joined: 16 Dec 2006
Contact:

Re: Dynamic Arrays, Functions, Lists

Postby ABC » 20 Mar 2017

You can pass dynamic arrays to functions. Check out page 109 of the EL Essentials PDF and the examples there.
You'll have to check out what happens when you change the array size within the function.

Regards,

ABC


Return to “MultiCharts”