5. Embedded QUEL for Ada : Ada Variables and Data Types : Variable and Type Declarations : The Character and String Data Types
 
Share this page                  
The Character and String Data Types
Both the character and string data types are compatible with Ingres string objects. By default, the string data type is an array of characters.
The character data type does have some restrictions. Because it must be compatible with Ingres string objects, you can use only a one-dimensional array of characters. Therefore, you cannot use a single character or a multidimensional array of characters. Note that you can use a multidimensional array of strings.
For example, the following four declarations are legal:
## subtype Alphabet is Character range 'a'..'z';
## type word_5 is array(1..5) of Character; 
                                    -- 1-dimensional array
## word_6: String(1..6);            -- Default string type
## word_arr: array(1..5) of String(1..6);
                                    -- Array of strings
However, the declarations below are illegal, because they violate the EQUEL restrictions for the character type. Although the declarations may not generate EQUEL errors, the references will not be accepted by the Ada compiler when used with EQUEL statements. For example:
## letter: Character; -- 1 character
## word_arr: array(1..5) of word_5; 
                      -- 2-dimensional array of char
Both could be declared instead with the less restrictive string type:
## letter: array(1..1) of Character;-- or equivalently...
## letter: String(1..1);
## word_arr: array(1..5) of String(1..6);   -- Array of strings