I am trying to programmatically change the “Use only
local database” from “yes” to “no” for all the
tickers in my database. Reading the manual, I saw “Stock” has a
property called DataLocalMode. I am assuming that it takes on value 0 for no
and 1 for yes. I modified one of TJ jscript codes to achieve my objective as
shown below. It is supposed to read from text file that contains the tickers
followed by a comma and a 0 (e.g. IBM,0). However, I am not successful. Do you
see the problem with my code? TIA
var filename = "c:\\amibroker\\List3.txt";
var fso, f, r;
var ForReading = 1;
var AmiBroker;
var fields;
var stock;
/* Create AmiBroker app object */
AB = new ActiveXObject("Broker.Application");
AB.LoadDatabase("c:\\Amibroker\\Data1Min");
AB.Visible = true;
/* ... and file system object */
fso = new ActiveXObject(
"Scripting.FileSystemObject" );
/* open ASCII file */
f = fso.OpenTextFile( filename, ForReading);
/* read the file line by line */
while ( !f.AtEndOfStream )
{
r = f.ReadLine();
/* split the lines using comma as a separator */
fields = r.split(",");
/* add a ticker - this is safe operation, in case that */
/* ticker already exists, AmiBroker returns existing one */
stock = AB.Stocks.Add( fields[ 0 ] );
stock.DataLocalMode = fields[ 1 ];
}
/* refresh ticker list and windows */
AB.RefreshAll();
WScript.echo("Local Mode Assignment Completed");