For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > March 2008 > OLE









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author OLE
Octavian Rasnita

2008-03-26, 8:03 am

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

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com