Help needed using Elcollections

Questions about MultiCharts and user contributed studies.
arjfca
Posts: 1270
Joined: 23 Nov 2010
Has thanked: 720 times
Been thanked: 222 times

Help needed using Elcollections

Postby arjfca » 04 Jul 2011

Hello

I'm seeking help for using ElCollections files functions. I have work the whole day using this collection and Global Variable and I have not progressed at all in either.

I want to read the single line of a text document in a string variable, but I just don't get it on how to read it as a CSV text file**.
CSVData.Txt = DataReady,EUR.USD,Buy Stop,37000,1.4367,Stop Loss, 1.4345

Code: Select all

 
Var: TextString ("");

value5 = Listc.Readfile(ID,"f:\temp\TestData\CSVData.Txt");

How do I get the ID number?
How do I store the result value in my variable TextString

Martin

** Does't need to be read as a csv. I will process it using Instr function
Attachments
CSVData.txt
(57 Bytes) Downloaded 30 times

User avatar
furytrader
Posts: 353
Joined: 30 Jul 2010
Location: Chicago, IL
Has thanked: 154 times
Been thanked: 215 times

Re: Help needed using Elcollections

Postby furytrader » 05 Jul 2011

I think what you have to do is to first create a List variable (of the ListC type) and then populate that list with the contents of your text file.

After you've done that, you can use ELCollections built-in functions (like ListC.Get) to retrieve the contents of that text file (which have been loaded into your list) and put them into a variable which you can analyze and manipulate.

So, I believe it would work something like this:

Code: Select all

Vars: vSampleList(ListC.New);

value1 = ListC.ReadFile(vSampleList,"f:\temp\TestData\CSVData.Txt");


So, again, the collection list vSampleList, will now contain the contents of your file. Note that because you're using a ListC (a list of collections), I believe the list (vSampleList) will contain sub-lists. Consequently, when you retrieve the contents of the file, you may need to first define a second list variable (of the type ListS (string) or ListN (number)) into which the contents of the particular sub-list will be dumped. You could then cycle through each entry of the sublist to get the information you want.

For me, ELCollections can get a little confusing when it comes to lists of lists, maps of lists, etc. The documentation is pretty good in providing examples though (see page 14 specifically for some ideas). Anyway, if you can't get this to work, let me know and I will see what else I can do to help.

Good luck!
These users thanked the author furytrader for the post (total 3):
arjfcaStan BokovJoshM

arjfca
Posts: 1270
Joined: 23 Nov 2010
Has thanked: 720 times
Been thanked: 222 times

Re: Help needed using Elcollections

Postby arjfca » 05 Jul 2011

furytrader wrote:I think what you have to do is to first create a List variable (of the ListC type) and then populate that list with the contents of your text file.

For me, ELCollections can get a little confusing when it comes to lists of lists, maps of lists, etc. The documentation is pretty good in providing examples though (see page 14 specifically for some ideas). Anyway, if you can't get this to work, let me know and I will see what else I can do to help.

Good luck!


I'm indeed confuse :)
Variable:

MyBigString ("Allo Martin"),
String2 (""),
StoreValue (0),
MyStringLoc (1),
Price (1.4635),
TextFile (""),
ListID(ListS.New);

If lastbaronchart then
begin
value1 = ListS.Readfile(listid,"f:\temp\TestData\CSVData.Txt");
TextFile = Lists.Get(ListID,1);
Print (value1, ListID:0:0, " ", textFile);


I added the line TextFile = Lists.Get(ListID,1);

And now it seems to work

Many thanks for that one

Martin


Return to “MultiCharts”