load input parameter from INI file

 

Hi,

I want to set an input parameter using INI file. For a single symbol it works find but I want to use it for multi-currency purpose. Here's the code that I use,

input string InpSettingsFile = "Lybra/Test/external file.ini";    //input file name, blank = not used

int StoplossPoint, TakeProfitPoint;
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart() {
//---
   if(LoadFileMultiCurrency()) {
      Print("stoploss point: ", StoplossPoint);
      Print("take profit point: ", TakeProfitPoint);
   }
}
//+------------------------------------------------------------------+
bool LoadFileMultiCurrency() {
   bool result = false;
//for(int SymbolLoop=0; SymbolLoop < NumberOfTradeableSymbols; SymbolLoop++) {

   if(InpSettingsFile == "")
      return result;
   if(!FileIsExist(InpSettingsFile))
      return result;

   static long lastModDate = 0;
   long        modDate     = FileGetInteger(InpSettingsFile, FILE_MODIFY_DATE);

   if(modDate == lastModDate)
      return (result);
   lastModDate = modDate;

   string key     = "";
   string svalue  = "";
   string line    = "";
   string parts[];

   int handle = FileOpen(InpSettingsFile, FILE_SHARE_READ | FILE_TXT | FILE_ANSI);
   if(handle == INVALID_HANDLE)
      return (result);
   FileSeek(handle, 0, SEEK_SET);

   while(!FileIsEnding(handle)) {
      line = FileReadString(handle);
      StringSplit(line, '=', parts);
      key    = "";
      svalue = "";
      int size = ArraySize(parts);
      if(size > 0)
         key = parts[0];
      if(size > 1)
         svalue = parts[1];
      StringToLower(key);

      //evaluate the inputs
      if(key == "stoplosspoint")
         result |= SetValue(StoplossPoint, (int) StringToInteger(svalue));
      if(key == "takeprofitpoint")
         result |= SetValue(TakeProfitPoint, (int) StringToInteger(svalue));
   }
   FileClose(handle);

   return(result);
}

template <typename T> bool SetValue(T& currentValue, T newValue) {
   if(currentValue != newValue) {
      currentValue = newValue;
      return (true);
   }
   return (false);
}
//+------------------------------------------------------------------+

INI file content:

StoplossPoint=40
TakeProfitPoint=40

What I want to do is something like this:

[EURUSD]
StoplossPoint=40
TakeProfitPoint=40
[USDJPY]
StoplossPoint=40
TakeProfitPoint=40
[EURCAD]
StoplossPoint=40
TakeProfitPoint=40

How can I do that?