is there a function to unify text?

 

Greetings,


I would like to know if there is a function to convert text from Uppercase to Lowercase and vise verse.

something like this:


Let's say string variable 'a' might contain some version of the word 'buy';

instead:  if (a=="buy" or a=="Buy" or a=="BUY")..  etc.

I'd like to use: if ("buy"==f(a)..)      //where  f(a) return all strings as lowercase.


James
 
JJF:

Greetings,


I would like to know if there is a function to convert text from Uppercase to Lowercase and vise verse.

something like this:


Let's say string variable 'a' might contain some version of the word 'buy';

instead:  if (a=="buy" or a=="Buy" or a=="BUY")..  etc.

I'd like to use: if ("buy"==f(a)..)      //where  f(a) return all strings as lowercase.


James


You have to create that function using ASCII codes. 

Unfortunately I only have the one that set to uppercase :

//+------------------------------------------------------------------+
string RETURN_UPPERCASE (string text) // 
  {
  // ASCII Code for UPPER CASE is 32 smaller than LOWER CASE
  // A is 65, a is 97, Z is 90 , z is 122
  int Length, Total_Length, Count;
  
  Total_Length = StringLen (text);
  for (Count = 0; Count <= Total_Length; Count ++)
    {
    Length = StringGetChar (text, Count);
    if (Length >= 97 && Length <= 122) // lower case
      {
      Length -= 32;
      text = StringSetChar(text, Count, Length );
      }
      else
      {
      if (Length < 65 && Length > 90) // other than upper case and other than  lower case
        {
        text = StringSetChar(text, Count, Length ); // we don't change anything
        }
      }
    }
  
  return (text);
  }
//+------------------------------------------------------------------+
Reason: