

Character Facilities The length of a literal character constant is just the number of characters between
the enclosing apostrophes (except that two consecutive apostrophe within the string
count as one). Thus:
'it''s'
is a character constant of length four. Because the length of every character variable,
array, and function has to be specified in advance it is nearly always necessary to use
CHARACTER statements to declare them, for example:
CHARACTER NAME*20, ADDRSS(3)*40, ZIP*7
The same applies to named character constants but for these a special notation sets
the length to that of the attached constant, which saves the trouble of counting
characters:
CHARACTER TITLE*(*) PARAMETER (TITLE = 'Latest mailing list') |
When transferring character information to procedures the length of the dummy argument can be set automatically to that of the corresponding actual argument. With this passed length notation it is easy to write general-purpose character handling procedures. This is described further in section 9.5.
The most common operations carried out on character strings are splitting them up and joining them together. Any section of a character variable or array element can be extracted by using the substring notation. Strings (and substrings) can be joined end to end by using the concatenation operator in a character expression. These are described in the next two sections.
Another fairly common requirement is to search for a particular sequence of
characters within a longer string: this can be done with the intrinsic function
INDEX.
Other intrinsic functions ICHAR and CHAR are provided to convert a single
character to an integer or vice-versa according to its position within the native
character set. More complicated conversions from a numerical data type to character
form and vice-versa are best carried out using the internal file READ and WRITE
statements which allow the power of the format specification to applied to the task.
This mechanism is described in section 10.3.
Character strings can be compared to each other using relational operators or intrinsic functions. The latter use the ASCII collating sequence irrespective of the native character code. Further details are given in section 7.6.