StringReplace() deprecated?? [warning 91: deprecated behavior, hidden method calling will be disabled in a future MQL compiler version]

 

The current compiler build 2170 of Metatrader 5 is acusing All my StringReplace() on MQ5 code as deprecated.


warning 91: deprecated behavior, hidden method calling will be disabled in a future MQL compiler version


What to do?!! What is the replacement to this function? Any ways to solve it?

 
Do you really expect an answer? We can't see your broken code — we can only guess. There are no mind readers here and our crystal balls are cracked.
 
William Roeder:
Do you really expect an answer? We can't see your broken code — we can only guess. There are no mind readers here and our crystal balls are cracked.

Just Import this telgram lib with it's dependencies to your \include folder (I attached here all the files) to any project of yours and try to compile it. Voylla! There you are, Warning 91 to all the StringReplace() functions.

 
Documentation
 Telegram.mqh
int  StringReplace(
   string&         str,              // the string in which substrings will be replaced
   const string    find,             // the searched substring
                                                                                                  
   const string    replacement       // the substring that will be inserted to the found positions
   );
StringReplace(
   text,
   pos,
   6,
   ShortToString((ushort)dec)
);
 
owneroxxor:

The current compiler build 2170 of Metatrader 5 is acusing All my StringReplace() on MQ5 code as deprecated.


warning 91: deprecated behavior, hidden method calling will be disabled in a future MQL compiler version


What to do?!! What is the replacement to this function? Any ways to solve it?

mql5 StringReplace() function is not deprecated. What is deprecated is "hidden" method calling.

In your lib StringReplace() is overloaded and that's the problem.

Add the global scope operator before each call the mql5 StringReplace occurence and the warnings are gone.

      ::StringReplace(text,";"," ");
 
I just didn't see that it was overloaded inside the class, damn it. Thanks Alain and Will. Adding :: in front worked!
 
Alain Verleyen:

mql5 StringReplace() function is not deprecated. What is deprecated is "hidden" method calling.

In your lib StringReplace() is overloaded and that's the problem.

Add the global scope operator before each call the mql5 StringReplace occurence and the warnings are gone.

Thanks man. This info helped. It is only working answer I've found in seven days. 

 

Hello:


The same thing happens to me and adding what they comment disappear the warnings ... but I don't quite understand what "::" is and how in the future they will replace this function ...


Thanks, as always!

 
odlambda:

Hello:


The same thing happens to me and adding what they comment disappear the warnings ... but I don't quite understand what "::" is and how in the future they will replace this function ...


Thanks, as always!

It's not about this function (StringReplace), read again and try to understand. All is already explained.
 

I had the same problem with another library, where there were classes that inherited functions without parameters, but added new parameters to them

Now, you have to clarify which version of the function you are calling (even though they have a different amount of parameters, but that seems will be deprecated "soon")

//3 parameters: use the standard definition of StringReplace (Global scope)
StringReplace(text,"\n",ShortToString(0x0A)); /* ---> */ ::StringReplace(text,"\n",ShortToString(0x0A));

//4 parameters: use the function that is defined in THIS class (Local scope)
StringReplace(text,pos,6,ShortToString((ushort)result)); /* ---> */ CCustomBot::StringReplace(text,pos,6,ShortToString((ushort)result));
Reason: