FORTRAN 77 Language Reference

Character String Assignment

The form of the character string assignment is:

v = e

e

Expression giving the value to be assigned 

v

Variable, array element, substring, or character record field 

The meaning of character assignment is to copy characters from the right to the left side.

Execution of a character assignment statement causes evaluation of the character expression and assignment of the resulting value to v.

Example: The following program below displays joinedDD:


	CHARACTER A*4, B*2, C*8 
	A = 'join'
	B = 'ed'
	C = A // B 
	PRINT *, C 
	END 

Also, this program displays the equal string:


	IF ( ('ab' // 'cd') .EQ. 'abcd' ) PRINT *, 'equal'
	END

Example: Character assignment:


	CHARACTER BELL*1, C2*2, C3*3, C5*5, C6*6 
	REAL Z
	C2 = 'z' 
	C3 = 'uvwxyz' 
	C5 = 'vwxyz' 
	C5(1:2) = 'AB' 
	C6 = C5 // C2 
	I = 'abcd' 
	Z = 'wxyz'
	BELL = CHAR(7)    Control Character (^G)

The results are:

Variable 

Receiving Value 

Comment 

C2

'zD'

A trailing blank 

C3

'uvw'

 

C5

'ABxyz'

 

C6

'ABxyzz'

The final 'z' comes from C2

I

'abcd'

 

Z

'wxyz'

 

BELL

07 hex

Control-G, a bell

Example 4: A Hollerith assignment: @


	CHARACTER S*4 
	INTEGER I2*2, I4*4 
	REAL R 
	S = 4Hwxyz 
	I2 = 2Hyz 
	I4 = 4Hwxyz 
	R = 4Hwxyz