Hi,
Can anyone give me some hints about how I could translate a simple JScript
function into a perl one?
The script is below, but what I don't know how to do are the following
lines:
AmiBroker = new ActiveXObject( "Broker.Application" );
fso = new ActiveXObject( "Scripting.FileSystemObject" );
stock = AmiBroker.Stocks.Add( fields[ 0 ] );
WScript.Echo( "Importing " + fields[ 0 ] );
date = new Date( fields[ 2 ] );
quote = stock.Quotations.Add( date.getVarDate() );
quote.High = parseFloat( fields[ 3 ] );
AmiBroker.RefreshAll();
Of course, some hints about how can I start doing this, will help me.
Thank you.
Here is the whole script:
function ImportMsASCII( filename )
{
var fso, f, r;
var ForReading = 1;
var AmiBroker;
var date;
var quote;
var fields;
var stock;
/* Create AmiBroker app object */
AmiBroker = new ActiveXObject( "Broker.Application" );
/* ... and file system object */
fso = new ActiveXObject( "Scripting.FileSystemObject" );
/* open ASCII file */
f = fso.OpenTextFile( filename, ForReading);
/* skip first line which contains format definition */
f.SkipLine();
/* 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 = AmiBroker.Stocks.Add( fields[ 0 ] );
/* notify the user */
WScript.Echo( "Importing " + fields[ 0 ] );
/* parse the date from the text file */
date = new Date( fields[ 2 ] );
/* add a new quotation */
quote = stock.Quotations.Add( date.getVarDate() );
/* put data into it */
quote.High = parseFloat( fields[ 3 ] );
quote.Low = parseFloat( fields[ 4 ] );
quote.Close = quote.Open = parseFloat( fields[ 5 ] );
quote.Volume = parseInt( fields[ 6 ] );
}
/* refresh ticker list and windows */
AmiBroker.RefreshAll();
/* notify the user */
WScript.Echo( "Finished" );
}
Octavian
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/