Download MetaTrader 5

UpperCase, LowerCase

To add comments, please log in or register
Yi Zhu
32
Yi Zhu  
Does MT4 has a function can convert upper case to lower case and vice versa? It could be very handy.

cheers.
sx ted
22
sx ted  
string StringChangeToUpperCase(string sText) {
  // Example: StringChangeToUpperCase("oNe mAn"); // ONE MAN 
  int iLen=StringLen(sText), i, iChar;
  for(i=0; i < iLen; i++) {
    iChar=StringGetChar(sText, i);
    if(iChar >= 97 && iChar <= 122) sText=StringSetChar(sText, i, iChar-32);
  }
  return(sText);
}
 
string StringChangeToLowerCase(string sText) {
  // Example: StringChangeToLowerCase("oNe mAn"); // one man
  int iLen=StringLen(sText), i, iChar;
  for(i=0; i < iLen; i++) {
    iChar=StringGetChar(sText, i);
    if(iChar >= 65 && iChar <= 90) sText=StringSetChar(sText, i, iChar+32);
  }
  return(sText);  
}
 
string StringChangeFirstToUpperCase(string sText) {
  // Example: StringChangeFirstToUpperCase("oNe mAn"); // One Man
  int iLen=StringLen(sText), i, iChar, iLast=32;
  for(i=0; i < iLen; i++) {
    iChar=StringGetChar(sText, i);
    if(iLast==32 && iChar >= 97 && iChar <= 122) sText=StringSetChar(sText, i, iChar-32);
    else if(iLast!=32 && iChar >= 65 && iChar <= 90) sText=StringSetChar(sText, i, iChar+32);
    iLast=iChar;
  }
  return(sText);  
}
Neil
53
Neil  
sx_ted: [string conversion functions]

Thanks for posting these!

Angga Wirapraditya
162
Angga Wirapraditya  
Great stuff bro .. thanks
To add comments, please log in or register