PureBytes Links
Trading Reference Links
|
Michael,
Thanks. A quick question. In PERL one can keep adding elements to
an array by statements such as
push( @arrayOfTickers, $ticker1 );
push( @arrayOfTickers, $ticker2 );
push( @arrayOfTickers, $ticker3 );
...
...
...
Beauty is that one need not know beforehand how many elements are to
be added. (Therefore it's not necessary to know how many tickers are
there in Spread-Sheet beforehand.)
What's equivalent in JScript ?
Regards,
- Salil V Gangal
--- In amibroker@xxxxxxxxxxxxxxx, "Michael.S.G." <OzFalcon@xxxx>
wrote:
> Opps, Big bug in that code.
>
> I forgot to close the file in the function.......... I do sugest
you fix
> this before trying this code.
>
> Here is new code, Untested.
>
>
>
> /*
> ** AmiBroker/Win32 script.
> **
> ** File:
> ** Updated: January 18th, 2004
> ** Purpose:
> ** Language: JavaScript (Windows Scripting Host)
> **
> ** The data is stored in lines with following format
> **
> **
> */
>
> /* change this line according to your data file name */
> base = "am200401/am200401";
> STicker = "GOLD";
> /* Output file is STicker.csv */
>
>
> WScript.Echo( "Ticker Find Started" );
>
> var fso, fw, f, r;
> var FName, outfile;
> var ForReading = 1;
> var ForWriting = 2;
> var ForAppending = 8;
>
> /* Create file system object */
> fso = new ActiveXObject( "Scripting.FileSystemObject" );
>
> outfile = STicker + ".csv";
> fw = fso.OpenTextFile( outfile, ForAppending, false);
>
> for( L1 = 1; L1 < 34; L1++ )
> {
> basename = base;
> if (L1 < 10)
> {
> basename = basename + "0";
> }
> FName = basename + (L1)+".prn";
> ImportStocks(FName);
> }
> fw.Close();
>
> WScript.Echo( "Ticker Find Finished" );
>
>
> function ImportStocks( filename )
> {
> var fields;
> var ticker;
>
> try
> {
>
> /* 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(",");
>
> ticker = fields[0];
> if (ticker == STicker)
> {
> fw.WriteLine( r );
> }
> }
> }
> catch ( e )
> {
>
> WScript.echo( "There is a problem in file no." + L1 + ".\n"+
filename +
> "\nIt will be skipped and next file will be processed as normal" );
>
> }
> f.close()
> }
------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/GHeqlB/TM
---------------------------------------------------------------------~->
Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> 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/
|