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.

Assignment Statements<br />

While the variable i is defined with a statement label, it should not be used in any other way other than in<br />

an assigned GO TO statement. Consider the following example.<br />

Example:<br />

10 ASSIGN 10 TO I<br />

* Illegal use of an ASSIGNed variable<br />

PRINT *, I<br />

The output produced by the PRINT statement is not the integer 10. Its value is undefined and should be<br />

treated that way.<br />

8.5 Character Assignment<br />

The form of a character assignment statement is<br />

<br />

v = e<br />

where:<br />

v<br />

e<br />

is a character variable name, character array element, or character substring.<br />

is a character expression.<br />

The following are examples of character assignment statements.<br />

CHARACTER*20 C,D(5)<br />

C=’ABCDEF’<br />

C(3:5)=’XYZ’<br />

D(5)(14:15)=’12’<br />

Executing a character assignment statement causes the evaluation of the character expression e and the<br />

definition of v with the result.<br />

None of the character positions defined in v may be referenced in e. The following example is illegal<br />

since the 4th and 5th character positions of A appear on the left and right hand side of the equal sign.<br />

Example:<br />

* Illegal character assignment.<br />

CHARACTER*10 A,B*5<br />

A(2:6) = A(4:5) // B<br />

The length of v and e may be different. If the length of v is less than the length of e then the assignment<br />

has the effect of truncating e from the right to the length of v. If the length of v is greater than the length<br />

of e, the value assigned to v is the value of e padded on the right with blanks to the length of v.<br />

Character Assignment 189

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

Saved successfully!

Ooh no, something went wrong!