This forum is in read-only mode now. You may discuss your questions on forums of MQL4.community and MQL5.community

StringFind() problems?


Back to topics list
avatar
153
CoenWillemse 2004.12.08 12:26 
I think I've discovered a problem with the MQL function "StringFind()" in MetaTrader 4. When running the following code:

endIndex = StringFind("abcdefg abcdefg","d",9);
Print(endIndex);
return(0);

I get the error: "invalid integer number as parameter 1 for StringFind function". However, 'endIndex' ends up equaling 3 which is position of the first 'd'; not the second one.

Anyone else come across this problem?
avatar
4464
Slawa 2004.12.08 13:51 
will be fixed. thanxx for info
avatar
153
CoenWillemse 2004.12.10 03:27 
Just downloaded Build 137 and my original stringFind() problem has been fixed. I have noticed however that it seems to work in a different way to implementations of this type of function that I've seen in other languages.

e.g. In this example:

string splitString = "abcdefg abcdefg";
endIndex = StringFind(splitString,"c", 0);

endIndex = 2 which is fine. However, in the next example:

string splitString = "abcdefg abcdefg";
endIndex = StringFind(splitString,"c", 3);

endIndex = 7, (endIndex should actually = 10 if counting from the beginning of the string). It appears that StringFind() is starting to count from the offset (3), rather than counting from the beginning of the string. Is this the way that it's supposed to work?

avatar
4464
Slawa 2004.12.10 12:35 
thanx
avatar
153
CoenWillemse 2004.12.13 04:22 
StingFind() fixed in build 138 - thanx Slawa!
Back to topics list  
Download MetaTrader 5 (450 Kb, web installer) — a new terminal for financial markets