StringFind

Dizgi içinde bir alt-dizgiyi arar.

int  StringFind(
   string  string_value,        // aramanın yapılacağı dizgi
   string  match_substring,     // aranan
   int     start_pos=0          // arama hangi konumdan başlayacak
   );

Parametreler

string_value

[in]  Aramanın yapıldığı dizgi.

match_substring

[in]  Aranan alt-dizgi.

start_pos=0

[in]  Dizgi içinde aramanın başlayacağı konum.

Dönüş değeri

Alt-dizginin başladığı konuma dönüş yapar, alt-dizgi bulunamazsa -1 dönüşü yapar.

Örnek:

#define   RESERVE    100
 
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//--- sembol baz para birimini ve kâr para birimini al
   string symbol_currency_base  =SymbolInfoString(Symbol(), SYMBOL_CURRENCY_BASE);
   string symbol_currency_profit=SymbolInfoString(Symbol(), SYMBOL_CURRENCY_PROFIT);
   PrintFormat("Symbol Currency Base: %s\nSymbol Currency Profit: %s"symbol_currency_basesymbol_currency_profit);
   
//--- sunucuda bulunan tüm semboller kullanılarak döngü içerisinde
   int total=SymbolsTotal(false), pos=-1;
   for(int i=0i<totali++)
     {
      //--- bir sonraki sembolün adını al
      string name=SymbolName(ifalse);
      
      //--- sembol adında baz para biriminin adını içeren bir alt dizge ara ve
      //--- bir alt dizge bulunursa, sembol adını, para birimi listesindeki indeksini ve aranan para biriminin adını günlükte görüntüle
      pos = StringFind(namesymbol_currency_base);
      if(pos >= 0)
         PrintFormat("The '%s' symbol at index %u in the list contains the '%s' currency. Substring position in the symbol name: %d"nameisymbol_currency_basepos);
         
      //--- sembol adında karşıt para biriminin adını içeren bir alt dizge ara ve
      //--- bir alt dizge bulunursa, sembol adını, para birimi listesindeki indeksini ve aranan para biriminin adını günlükte görüntüle
      pos = StringFind(namesymbol_currency_profit);
      if(pos >= 0)
         PrintFormat("The '%s' symbol at index %u in the list contains the '%s' currency. Substring position in the symbol name: %d"nameisymbol_currency_profitpos);
     }
      
  /*
  Sonuç
   StringFind (EURUSD,D1)   Symbol Currency BaseEUR
   StringFind (EURUSD,D1)   Symbol Currency ProfitUSD
   The 'EURUSDsymbol at index 0 in the list contains the 'EURcurrencySubstring position in the symbol name0
   The 'EURUSDsymbol at index 0 in the list contains the 'USDcurrencySubstring position in the symbol name3
   The 'GBPUSDsymbol at index 1 in the list contains the 'USDcurrencySubstring position in the symbol name3
   The 'USDCHFsymbol at index 2 in the list contains the 'USDcurrencySubstring position in the symbol name0
   The 'USDJPYsymbol at index 3 in the list contains the 'USDcurrencySubstring position in the symbol name0
   The 'USDCNHsymbol at index 4 in the list contains the 'USDcurrencySubstring position in the symbol name0
   The 'USDRUBsymbol at index 5 in the list contains the 'USDcurrencySubstring position in the symbol name0
   The 'AUDUSDsymbol at index 6 in the list contains the 'USDcurrencySubstring position in the symbol name3
   The 'NZDUSDsymbol at index 7 in the list contains the 'USDcurrencySubstring position in the symbol name3
   The 'USDCADsymbol at index 8 in the list contains the 'USDcurrencySubstring position in the symbol name0
   The 'USDSEKsymbol at index 9 in the list contains the 'USDcurrencySubstring position in the symbol name0
   The 'USDHKDsymbol at index 10 in the list contains the 'USDcurrencySubstring position in the symbol name0
   The 'USDSGDsymbol at index 11 in the list contains the 'USDcurrencySubstring position in the symbol name0
   The 'USDNOKsymbol at index 12 in the list contains the 'USDcurrencySubstring position in the symbol name0
   The 'USDDKKsymbol at index 13 in the list contains the 'USDcurrencySubstring position in the symbol name0
   The 'USDTRYsymbol at index 14 in the list contains the 'USDcurrencySubstring position in the symbol name0
   The 'USDZARsymbol at index 15 in the list contains the 'USDcurrencySubstring position in the symbol name0
   The 'USDCZKsymbol at index 16 in the list contains the 'USDcurrencySubstring position in the symbol name0
   The 'USDHUFsymbol at index 17 in the list contains the 'USDcurrencySubstring position in the symbol name0
   The 'USDPLNsymbol at index 18 in the list contains the 'USDcurrencySubstring position in the symbol name0
   The 'USDRURsymbol at index 19 in the list contains the 'USDcurrencySubstring position in the symbol name0
   The 'EURAUDsymbol at index 27 in the list contains the 'EURcurrencySubstring position in the symbol name0
   The 'EURCADsymbol at index 28 in the list contains the 'EURcurrencySubstring position in the symbol name0
   The 'EURCHFsymbol at index 29 in the list contains the 'EURcurrencySubstring position in the symbol name0
   The 'EURCZKsymbol at index 30 in the list contains the 'EURcurrencySubstring position in the symbol name0
   The 'EURDKKsymbol at index 31 in the list contains the 'EURcurrencySubstring position in the symbol name0
   The 'EURGBPsymbol at index 32 in the list contains the 'EURcurrencySubstring position in the symbol name0
   The 'EURHKDsymbol at index 33 in the list contains the 'EURcurrencySubstring position in the symbol name0
   The 'EURHUFsymbol at index 34 in the list contains the 'EURcurrencySubstring position in the symbol name0
   The 'EURJPYsymbol at index 35 in the list contains the 'EURcurrencySubstring position in the symbol name0
   The 'EURNOKsymbol at index 36 in the list contains the 'EURcurrencySubstring position in the symbol name0
   The 'EURNZDsymbol at index 37 in the list contains the 'EURcurrencySubstring position in the symbol name0
   The 'EURPLNsymbol at index 38 in the list contains the 'EURcurrencySubstring position in the symbol name0
   The 'EURRURsymbol at index 39 in the list contains the 'EURcurrencySubstring position in the symbol name0
   The 'EURRUBsymbol at index 40 in the list contains the 'EURcurrencySubstring position in the symbol name0
   The 'EURSEKsymbol at index 41 in the list contains the 'EURcurrencySubstring position in the symbol name0
   The 'EURTRYsymbol at index 42 in the list contains the 'EURcurrencySubstring position in the symbol name0
   The 'EURZARsymbol at index 43 in the list contains the 'EURcurrencySubstring position in the symbol name0
   The 'XAUUSDsymbol at index 47 in the list contains the 'USDcurrencySubstring position in the symbol name3
   The 'XAUEURsymbol at index 48 in the list contains the 'EURcurrencySubstring position in the symbol name3
   The 'XAGUSDsymbol at index 50 in the list contains the 'USDcurrencySubstring position in the symbol name3
   The 'XAGEURsymbol at index 51 in the list contains the 'EURcurrencySubstring position in the symbol name3
   The 'USDCREsymbol at index 53 in the list contains the 'USDcurrencySubstring position in the symbol name0
   The 'XPDUSDsymbol at index 65 in the list contains the 'USDcurrencySubstring position in the symbol name3
   The 'XPTUSDsymbol at index 66 in the list contains the 'USDcurrencySubstring position in the symbol name3
   The 'USDGELsymbol at index 67 in the list contains the 'USDcurrencySubstring position in the symbol name0
   The 'USDMXNsymbol at index 68 in the list contains the 'USDcurrencySubstring position in the symbol name0
   The 'EURMXNsymbol at index 69 in the list contains the 'EURcurrencySubstring position in the symbol name0
   The 'USDCOPsymbol at index 75 in the list contains the 'USDcurrencySubstring position in the symbol name0
   The 'USDARSsymbol at index 76 in the list contains the 'USDcurrencySubstring position in the symbol name0
   The 'USDCLPsymbol at index 77 in the list contains the 'USDcurrencySubstring position in the symbol name0
   The 'EURSGDsymbol at index 89 in the list contains the 'EURcurrencySubstring position in the symbol name0
   The 'USDILSsymbol at index 95 in the list contains the 'USDcurrencySubstring position in the symbol name0
   The 'USDTHBsymbol at index 122 in the list contains the 'USDcurrencySubstring position in the symbol name0
   The 'USDRMBsymbol at index 123 in the list contains the 'USDcurrencySubstring position in the symbol name0
   The 'EURILSsymbol at index 126 in the list contains the 'EURcurrencySubstring position in the symbol name0
   The 'EURCNHsymbol at index 137 in the list contains the 'EURcurrencySubstring position in the symbol name0
   The 'USDBRLsymbol at index 139 in the list contains the 'USDcurrencySubstring position in the symbol name0
  */
  }

Ayrıca Bakınız

StringSubstr, StringGetCharacter, StringLen, StringLen