I use a simpler script to do the same thing.  There is an "Import ASCII" 
function under the left hand drop down menu "FILE"
I just write the following file in clear text, then 'Import' it.

ReefBreak

$FORMAT NAME, FULLNAME, MARKET, INDUSTRY
$OVERWRITE 1
$BREAKONERR 1
MYY, "ProShrs Shrt 1X MIDCP", 2, 250
QLD, "ProShrs Long 2X CUBES", 2, 250
SSO, "ProShrs Long 2X SP500", 2, 250
DDM, "ProShrs Long 2X DOW30", 2, 250
MVV, "ProShrs Long 2X MIDCP", 2, 250
QID, "ProShrs Shrt 2X CUBES", 2, 250
SDS, "ProShrs Shrt 2X SP500", 2, 250
DXD, "ProShrs Shrt 2X DOW30", 2, 250
MZZ, "ProShrs Shrt 2X MIDCP", 2, 250
 




--- In [email protected], "max.matsen" <max.mat...@...> wrote:
>
> Hi,
> 
> I've been trying for a couple of weeks to use a jvscript written in the book 
> Introduction to amibroker ( p.19 with reference to p. 565) with no success as 
> I keep getting syntax error by the compiler. The script should have read a 
> text  file I created that contains the 1000 tickers of the Russell 1000 Index 
> along with the full name of each issue and establish the database in AB.
> Can anybody help to identify the script error?
> /*
> ** Amibroker/Win32 scripting Example
> **
> ** File:       Industries.js
> ** Created:    Tomasz Janeczko, November 26th, 2000
> ** Last updated: Tomasz Janeczko, December 17th, 2000
> ** Purpose:    Import Industy assignments
> ** Language:    Javascript (Windows Scripting Host)
> **
> ** The data is stored in lines with following format
> ** <ticker>,<full name>,<industry number>
> **
> */
> 
> WScript.Echo( "Script Started" );
> 
> /* change this line according to your date file name */
> ImportStocks("r1000fullname.txt");
> 
> WScript.Echo( "Finished" );
> 
> function ImportStocks( filename )
> {
>       var fso, f, r;
>       var ForReading = 1;
>       var Amibroker;
>       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);
> 
>     i = 1;
>     /* read the file line by line */
>     while ( !f.AtEndOfStream )
>       {
>         r = f.ReadLine();
> 
>         /* split the lines using comma as a separator */
>         fields = r.split(",");
> 
>         try
>         {
> 
>             /* add a ticker - this is safe operation,
>                 in case that ticker already exists,
>                   Amibroker returns existing one */
>               stock = Amibroker.Stocks.Add( fields[ 0 ] );
> 
>               stock.FullName = fields[ 1 ];
> 
>               stock.IndustryID = parseInt( fields[ 2 ] );
>         }
>         catch( e )
>         {
>                  Wscript.echo( "There is a problem in line no."
>                  + i + ".\nThe line looks as follows:\n'" + r
>                  + "'\nIt will be skipped and next lines will be 
>                                     processed as normal" );
> 
>         }
> 
>         i++;
>     }
> 
>       /* refresh ticker list and windows */
>       Amibroker.RefreshAll();
> 
> }
> 
> 
> Thanks
> pascal
>


Reply via email to