Thanks Mike, but I want to be clear(er).  My plan is to expand this simple 
example to get me at individual values in the array.  In this case, the 10 
values in the before.csv file provide information needed for 10 backtest runs.  
So, when I modifiy the JavaSript to loop thru the 10 backtests, I need to get 
at one and only one of the array values in before.csv.  For example, when the 
JavaScript loop is on number 5, then I need to get at the 5th item in the 
second line of before.csv or what I was thinking would be myarray(5) of 1.  
Know that you know this (and sorry for not being clear if I wasn't), does this 
change your reply? Thanks again!

--- In [email protected], "Mike" <sfclimb...@...> wrote:
>
> You need to store the value that you have read, then write that value. Unless 
> the lines in the file are very very long, a simple string will do.
> 
> var line;
> var fso, ts;
> 
> var ForReading = 1, ForWriting = 2, ForAppending = 8;
> var TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0;
> 
> var before = "C:\\Temp\\before.csv"
> var after = "C:\\Temp\\after.csv"
> 
> fso = new ActiveXObject("Scripting.FileSystemObject");
> ts = fso.OpenTextFile(before, ForReading, false, TristateUseDefault);
> 
> line = ts.ReadLine(); // First line
> line = ts.ReadLine(); // Second line
> ts.Close();
> 
> ts = fso.OpenTextFile(after, ForWriting, true, TristateUseDefault);
> ts.WriteLine(line);
> ts.Close();
> 
> Mike
> 
> 
> --- In [email protected], "bistrader" <bistrader@> wrote:
> >
> > Am trying to put together a simple JavaScript to eventually use with 
> > AmiBroker.  This JavaScript should ...
> > 
> > 1. Start out with the before.csv file.
> > A,B,C,D,E,F,G,H,I,J
> > 5,4,3,2,1,10,9,7,6,6
> > 
> > 2. Skip the first line and read the 10 numbers into an array.
> > 
> > 3. Write this array to a new after.csv file.
> > 
> > I am lost with all of my googling.  Here is what I have.  Help appreciated.
> > 
> > var myarray = new Array();
> > var fso, ts, ts2, i;
> > 
> > var ForReading = 1, ForWriting = 2, ForAppending = 8;
> > var TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0;
> > 
> > var before = "C:\\Amibroker\\Temp\\before.csv"
> > var after = "C:\\Amibroker\\Temp\\after.csv"
> > 
> > fso = new ActiveXObject("Scripting.FileSystemObject");
> > //object.OpenTextFile(filename, iomode, create, format)
> > ts = fso.OpenTextFile(before, ForReading, false, TristateUseDefault);
> > 
> > //ts.SkipLine();
> > //ts.ReadLine();
> > //myarray = ts.split(',');
> > 
> > for (i = 1; i <= 10; i++)
> > {
> > ts.ReadLine();
> > //ts.ReadLine();
> > ts.ReadLine(myarray[i]);
> > }
> > 
> > ts.Close();
> > 
> > 
> > ts2 = fso.OpenTextFile(after, ForWriting, true, TristateUseDefault);
> > ts2.Write(myarray + ',');
> > ts2.Close();
> > // The end
> >
>


Reply via email to