Author Topic: Help for change many symbol in the Dbase  (Read 2193 times)

kiss.sphinx

  • Newbie
  • *
  • Posts: 2
    • View Profile
Help for change many symbol in the Dbase
« on: November 22, 2016, 11:14:18 am »
I have many symbols in database with an old prefix (1 example is:  BE_XXX  ).
I want to change all ticker prefix in the database with [BE: or other prefix]  (to download and retrieve data from Google [without using translation file on Amiquote])

I have many hundred symbols in database and I don't know well the Language.

--------------------------------------------------------------------------------------------------
(I found this script (below) on the web (I try to modify it)... but I can't to resolve my problem)

Code: [Select]
AB = CreateObject("Broker.Application");
sts = AB.Stocks();
Qty = sts.Count;
for( i = Qty - 1; i >= 0; i = i - 1 )
{
 st = sts.Item( i );
 Ticker = st.Ticker; 
 printf("changing " + ticker + "\n" );
 Length = StrLen(Ticker );
 if( StrFind(ticker, ".TO") )
      st.Ticker = StrLeft( ticker, Length-3)+"-TC";
}
-----------------------------------------------------------------------

Can anyone help me to resolve this problem? I'm sure that's very simple but I'm a very novice programmer....
Thanks in advance

Kiss
« Last Edit: February 28, 2019, 12:22:36 am by administrator »

Peter5510

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Help for change many symbol in the Dbase
« Reply #1 on: February 06, 2019, 11:25:51 pm »
Code: [Select]
// Before running this Javascript, please backup your database
// Backup = Just copy your database to another location
// Change the Qty inside the "for loop" to a small number for testing purpose
// If it works, change back to Qty
AB = new ActiveXObject("Broker.Application");
sts = AB.Stocks;
Qty = sts.Count;
for( i = 0; i < Qty; i++) {
var ticker_sym = sts(i).Ticker;
// Use Javascript substring function to extract last 3 characters from Ticker name
// For example BE_XXX, to get symbol XXX, must use postion 2 to the last position
var new_ticker_sym = ticker_sym.substring(2,ticker_sym.length);
var prefix_text = ticker_sym.substring(0,3);
if( prefix_text == "BE_" ) {
sts(i).Ticker = "some other prefix" + "_" + new_ticker_sym;
}
}
« Last Edit: February 28, 2019, 12:22:58 am by administrator »