| 
 Hi Barry, 
  
Well the post I made earlier has not shown up yet -- Yahoo once again being 
selective with the ISPs it accepts email from? - so I'll repost as I also 
discovered that my post from the end of Sep was made with a different nom de net 
(TA4Charts) and didn't include the code, just made it an attachment which won't 
be on the web site and if you don't get emails and save them won't be 
available to you.   
  
So here is the full code: cut and paste to notebook, save with an extension 
of .js to the Scripts subfolder in Amibroker folder (watch out for line wraps), 
create a tool to invoke it, and you're good to go. 
  
Peace and Justice   ---   Patrick 
  
  
========================= 
  
/* ** AmiBroker/Win32 scripting Example ** ** 
File:  Cleanup.js ** Created:  Tomasz Janeczko, December 
2th, 2000   ** Modified:  Patrick Hargus, Oct 22, 2003  ** 
Purpose:  Cleanup the database from not traded stocks ** Language: 
  JScript (Windows Scripting Host) */ 
  
/* detection threshold (in days)  */  var Threshold = 20; // 
one month for example  /* by default do not delete = FALSE , EDITED TO TRUE 
so automatically deletes*/  var DeleteByDefault = true; /* ask the 
user for the decision - default is true  EDITED TO FALSE so no intervention 
required*/  var AskUser = 
false                        
 /* a timeout to wait until default route (no deletion) is taken 
*/  var Timeout = 5; 
  
 var oAB = new ActiveXObject("Broker.Application");  var fso = 
new ActiveXObject("Scripting.FileSystemObject");  var Shell = new 
ActiveXObject("WScript.Shell"); 
  
  var oStocks = oAB.Stocks; 
  
 var MiliSecInDay = 24 * 60 * 60 * 1000; 
  
 var Continue = true; 
  
 var StockQty = oStocks.Count; 
  
 var oStocksToDelete = new Array;  var oStocksNotTraded = new 
Array; 
  
if( ! AskUser ) WScript.Echo("Cleanup script started" ); 
  
for( i = 0; i < StockQty && Continue; i++ ) {  oStock 
= oStocks( i ); 
  
 var Qty = oStock.Quotations.Count;  
  
 var response = 0; 
  
 if( Qty > 0 )  {   oQuote = 
oStock.Quotations( Qty - 1 ); 
  
  var oDate = new Date( oQuote.Date ); 
  
  var Today = new Date(); 
  
  DaysNotTraded = Math.floor( ( Today - oDate )/MiliSecInDay 
); 
  
  if( DaysNotTraded > Threshold 
)   {    if( AskUser ) response = Shell.popup( 
oStock.Ticker + " is not traded since " + oDate.toLocaleString() + " (" + 
DaysNotTraded + " days).\nDo you wish to delete it?\n(Press Cancel to end the 
process)", Timeout, "Confirm delete", 3 + 256 
);    else          
response = -1; /* default 
*/   }  }  else  {   if( 
AskUser ) response = Shell.popup( oStock.Ticker + " has no quotes. Do you wish 
to delete it?",  Timeout, "Confirm delete", 3 + 256 
);   else          
response = -1; /* default */  } 
  
 /* change default route if needed */  if( response == -1 
&& DeleteByDefault ) response = 6; 
  
 switch( response )  {   case -1:/* Timeout - 
fallback to no */   case 7: /* No 
*/     oStocksNotTraded[ oStocksNotTraded.length ] = 
oStock.Ticker;     break;   case 6: /* Yes 
*/     oStocksToDelete[ oStocksToDelete.length ] = 
oStock.Ticker;     break;   case 2: /* 
Cancel */     Continue = 
false;     break;   default: 
break;  } } 
  
if( oStocksToDelete.length > 0 && Shell.popup( "You are now 
about to delete " + oStocksToDelete.length + " stock(s).\nDo you wish to 
proceed?" , 0, "Confirm delete", 4 + 256 ) == 6 ) {  for( i = 0; i 
< oStocksToDelete.length; i++ )  {   oStocks.Remove( 
oStocksToDelete[ i ]  );  } 
  
 oAB.RefreshAll(); } 
  
if( oStocksNotTraded.length > 0 && Shell.popup( "There are " + 
oStocksNotTraded.length + " not traded stock(s) detected but not deleted by your 
choice.\nDo you wish to save their tickers to \"nottraded.txt\" file?" , 0, 
"Confirm save", 4 + 256 ) == 6 ) {  f = fso.OpenTextFile( 
"nottraded.txt", 2, true );  
  
 for( i = 0; i < oStocksNotTraded.length; i++ 
)  {   f.WriteLine( oStocksNotTraded[ i ]  
);  } 
  
 f.Close(); } 
  
WScript.Echo("Cleanup script finished" ); 
  
  ----- Original Message -----  
  
  
  Sent: Saturday, October 29, 2005 10:26 
  PM 
  Subject: [amibroker] Script for database 
  cleanup 
  
  Has anyone changed the cleanup.js to eliminate the pop-up 
  windows and  just deleted any symbols that were inactive or have no quotes? 
  I would  really like to have a copy of it if it 
  exists.
  Thanks, Barry
 
 
  
  
Please note that this group is for discussion between users only. 
 
To get support from AmiBroker please send an e-mail directly to  
SUPPORT {at} amibroker.com 
 
For other support material please check also: 
http://www.amibroker.com/support.html 
 
  
    
  
  
  
    SPONSORED LINKS
   
       
  
 
  
    
  YAHOO! GROUPS LINKS
 
 
    
  |