[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: JavaScript Problem with Array


  • Date: Mon, 07 Dec 2009 00:51:00 -0000
  • From: "Mike" <sfclimbers@xxxxxxxxx>
  • Subject: [amibroker] Re: JavaScript Problem with Array

PureBytes Links

Trading Reference Links

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 amibroker@xxxxxxxxxxxxxxx, "bistrader" <bistrader@xxx> 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
>




------------------------------------

**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to 
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    amibroker-digest@xxxxxxxxxxxxxxx 
    amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/