MQL4参考 字符串函数 StringAdd

StringAdd

The function adds a substring to the end of a string.

bool  StringAdd(
   string&  string_var,        // string, to which we add
   string   add_substring      // string, which is added
   );

Parameters

string_var

[in][out]  String, to which another one is added.

add_substring

[in]  String that is added to the end of a  source string.

Return Value

In case of success returns true, otherwise false. In order to get an error code, the GetLastError() function should be called.

Example:

void OnStart()
  {
//---
   long length=10000000;
   string a="a",b="b",c;
//--- first method
   uint starttime=GetTickCount(),finishtime;
   long i;
   for(i=0;i<length;i++)
     {
      c=a+b;
     }
   finishtime=GetTickCount();
   Print("time for 'c = a + b' = ",(finishtime-starttime)," milliseconds, i = ",i);
 
//--- second method
   starttime=GetTickCount();
   for(i=0;i<length;i++)
     {
      StringAdd(a,b);
     }
   finishtime=GetTickCount();
   Print("time for 'StringAdd(a,b)' = ",(finishtime-starttime)," milliseconds, i = ",i);
 
//--- third method
   starttime=GetTickCount();
   a="a"//  re-initialize variable a
   for(i=0;i<length;i++)
     {
      c=StringConcatenate(a,b);
     }
   finishtime=GetTickCount();
   Print("time for 'c=StringConcatenate(a,b)' = ",(finishtime-starttime)," milliseconds, i = ",i);
  }

See also

StringConcatenate()