Examples: Strings: Table of ASCII Symbols and Its Use

 

New article Strings: Table of ASCII Symbols and Its Use has been published:

In this article we will analyze the table of ASCII symbols and the ways it can be used. We will also deal with some new functions, the principle of operation of which is based on the peculiarities of the ASCII table, and then we will create a new library, which will include these functions. They are quite popular in other programming languages, but they are not included into the list of built-in functions. Besides, we will examine in details the basics of working with strings. So, I think you will certainly learn something new about this useful type of data.

Author: Antoniuk Oleg

 

Hi,

I think, it would be better:

bool StringIsDigit(string str)
{
   bool result = true;
   int lenght = StringLen(str);
   if(lenght == 0) return(false);            <-- if it is not here, than result is true. Because while-condition (up) will be false.
   for(int i=0; i < lenght; i++)
   {
       int symbol = StringGetChar(str, i);
       if(symbol < 48 || symbol > 57)
       {
           result = false;
           break;
       }
   }
   return(result);
} 
 
//+------------------------------------------------------------------+
//| StringUpperCase                                                  |
//+------------------------------------------------------------------+
string StringUpperCase(string str)
  {
   string s = str;
   int lenght = StringLen(str) - 1, symbol;
   while(lenght >= 0)
     {
       symbol = StringGetChar(s, lenght);
       if((symbol > 96 && symbol < 123) || (symbol > 223 && symbol < 256))
           s = StringSetChar(s, lenght, symbol - 32);  // this part of codes gets error
       else 
           if(symbol > -33 && symbol < 0)
               s = StringSetChar(s, lenght, symbol + 224); // this part of codes gets error
       lenght--;
     }
   return(s);
  }
The value part of the StringSetChar gives a compilation error.
Reason: