Hi Martin, Your code will not work. You need to take the example in this link and modify it to your application.
viewtopic.php?f=1&t=6901
Here is how you need to think about it to understand it. You need to think of the CSV file being loaded into a special excel spread sheet that is contained inside memory within MultiCharts. Here is how it works.
In my code this command is basically the same as opening the excel spread sheet empty.
ListC_ID = ListC.new
In my code this command is the same as putting all the data from the whole CSV file (that is all rows at once) into the spread sheet that was opened up buy the ListC.new command.
Value1 = ListC.ReadFile(ListC_ID,"C:\EL_CollectionsTestData.txt");
In my code this set of commands is the same as setting pointers to point at each column of this special spread sheet that is inside memory within MultiCharts. There are 3 columns in my example so there are three of these commands. Think of these as the header names for each column. In your example you need 10 of these commands because you have 10 columns rather than 3 columns. You should create names that match the type of data that is in each column. Put a comment in your code indicating these are your column names and maybe put that right in the name. For example ListName_ID could be Column1_Name_ID. ListState_ID could be Column2_State_ID, ListAge_ID could be Column3_Age_ID. This will help you in the future remember that the 1,2,3 are column numbers.
ListName_ID = ListC.Get(ListC_ID,1); {pointing a column 1 of the spread sheet}
ListState_ID = ListC.Get(ListC_ID,2); {pointing a column 2 of the spread sheet}
ListAge_ID = ListC.Get(ListC_ID,3); {pointing a column 3 of the spread sheet}
In my code this set of 3 commands would get the first row from the excel spread sheet.
MyName = ListS.get(ListName_ID,1);
MyState = ListS.get(ListState_ID,1);
MyAge = ListN.get(ListAge_ID,1);
In my code this set of 3commands would get the 2nd row from the excel spread sheet.
MyName = ListS.get(ListName_ID,2);
MyState = ListS.get(ListState_ID,2);
MyAge = ListN.get(ListAge_ID,2);
In my code this set of commands would get the 3rd row from the excel spread sheet.
MyName = ListS.get(ListName_ID,3);
MyState = ListS.get(ListState_ID,3);
MyAge = ListN.get(ListAge_ID,3);
Of course you want to set it up as a loop rather than duplicate these commands over and over to get the column values for all the rows. So instead you use the exact method you are using in your loop (using the index as your loop pointer for processing each row of this special spread sheet inside Multicharts memory). You might want to rename the index to a word such as RowNumber so you can be reminded to think of each loop as processing a new row in what you are picturing in your mind as an excel sheet inside of MultiCharts in memory.
To make it easier to understand still, you could rename the receiving fields shown above better as I have shown below. Make it a standard that you use over and over when processing a CSV file. Here is what I would do.
CurrentRow_MyName = ListS.get(ListName_ID,RowNumber);
CurrentRow_MyState = ListS.get(ListState_ID,RowNumber);
CurrentRow_MyAge = ListN.get(ListAge_ID,RowNumber);
So you know that (during each loop through this special excel sheet you visualize inside of Multicharts memory) the above fields on the left always contain the data for the current row as each loop is processed.
Here is the same code but with all the renaming in place.
CurrentRow_MyName = ListS.get(Column1_Name_ID,RowNumber);
CurrentRow_MyState = ListS.get(Column2_State_ID,RowNumber);
CurrentRow_MyAge = ListN.get(Column3_Age_ID,RowNumber);
Basically you can see how these commands point to specific column/rows in the sheet.
If you expect to be adding and removing columns you could use this naming standard.
CurrentRow_MyName = ListS.get(Name_Column_ID,RowNumber);
CurrentRow_MyState = ListS.get(State_Column_ID,RowNumber);
CurrentRow_MyAge = ListN.get(Age_Column_ID,RowNumber);
By doing this you only need to adjust the column numbering in the one location.
This whole process of selecting descriptive names is called "making your code self documenting". I mention it in the debugging thread of the FAQ section the MultiCharts forum.
Give that a try. This is the way I am able to understand it. Actually maybe I should go back to all my code and do this. That way I would not have to figure it out again every single time I look at it - LOL. I often do this when I go back to my own code. I come up with changes such as this to make it easier to understand and change the next time around (the longer the time until the next change the more important doing this is). It always find that "the process of trying to figure out what my old code is doing" creates the best ideas for improved naming.
So if this is not clear then do this. Pull in my code and rename everything as I have done above until you understand it (until it will compile too). Next go back and apply this new understanding to your code.
John