24.11.2014 Views

Open Watcom FORTRAN 77 Language Reference

Open Watcom FORTRAN 77 Language Reference

Open Watcom FORTRAN 77 Language Reference

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Language</strong> <strong>Reference</strong><br />

7.2 Character Expressions<br />

Character expressions are used to describe computations involving operands of type CHARACTER, the<br />

concatenation operator (//) and left and right parentheses. The result of the computation is of type<br />

CHARACTER.<br />

7.2.1 Character Operators<br />

There is only one character operator, namely the concatenation operator (//). It requires two operands of<br />

type CHARACTER. If x is the left operand and y is the right operand, then the result is y concatenated to<br />

x. The length of the result is the sum of the lengths of the two operands. For example, the result of<br />

’AAAAA’//’BBB’<br />

is the string AAAAABBB.<br />

7.2.2 Rules for Forming Character Expressions<br />

The building blocks for character expressions are called character primaries. They are one of the<br />

following.<br />

1. character constant<br />

2. character symbolic constant<br />

3. character variable reference<br />

4. character array element reference<br />

5. character substring reference<br />

6. character function reference<br />

7. ( character expression )<br />

Character expressions are defined as follows:<br />

1. character primary<br />

2. character expression // character primary<br />

A character expression is simply a sequence of character primaries, each separated by the concatenation<br />

operator (//). Rule 2 implies that character primaries are combined from left to right. Except in a character<br />

assignment statement, the operands in a character expression must not contain operands whose length<br />

specification is (*) unless the operand is a symbolic constant.<br />

Note that, unlike arithmetic expressions, parentheses have no effect on the result of evaluating a character<br />

expression. For example, the result of the expressions<br />

and<br />

’A’//’B’//’C’<br />

’A’//(’B’//’C’)<br />

is identically the string ABC.<br />

178 Character Expressions

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!