[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 58
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I've rewritten the string replacement function with arrays:
string StrReplaceTwo(string text){
string textMod[] ={""};
string symbols1[] = {"12","15","19","13","14","16"};
string symbols2[] = {"a","b","c","d","e","f"};
string textNew="";
int textLen = StringLen(text);
for (int i1=0; i1<textLen; i1=i1+2)
{
string TwoSymbols = StringSubstr(text,i1,2);
for (int i2=0; i2<ArraySize(symbols1); i2++)
{
if (symbols1[i2]==TwoSymbols) {textNew = textNew + symbols2[ i2 ] ; i2=ArraySize(symbols1) ; }
}
}
return (textNew);
}
Now it goes through 2 characters per string, e.g. string 1215 will be replaced by ab. But I encountered a problem: the function omits characters that are not in the array and omits the last character if the string has an odd number of characters. Please help change the function so that string 1214153 it would replace with a14b3. Thank you!
Please help me change the function so that line 1214153 is replaced with a14b3. Thank you!
I don't understand the logic, you have 14 in the array, i.e. it should be replaced with "e". You can mess around with parity, but it's better to add zeros, i.e. replace 3 with 03.
I've reworked the string character replacement function a bit with arrays:
I think you're getting a bit wacky. If you need a substring replacement function, you can use this option:
I tweaked the end a bit, I didn't immediately notice the looping feature
I don't understand the logic, you have 14 in the array, i.e. it should be replaced by "e". You can mess around with parity, but it's better to add zeros, i.e. replace 3 with 03.
I think you're getting a bit wacky. If you need the substring replacement function, you can use this option:
Lians:
Oh, sorry, didn't notice, then let's say 1217153 to a17b3, about parity - the option of adding zeros would work, can you do that?
Thanks, but I can't compile it, it's crashing on a string:
if(x) textNew +=StrToInteger(TwoSymbols);
It's like this: '+=' - both operands are to be numeric
how do i fix it?
Thanks, but I can't compile it, it's crashing on a string:
It swears like this: '+=' - both operands are to be numeric
How do I fix it?
It does not work for strings in MQL4.
Thanks, but I can't compile it, it's crashing on a string:
it says: '+=' - both operands are to be numeric
How do I fix it?