C This software CHAREXMPL.FOR is part of the Visual Fortran kit.
C
C
C       CHARACTER DATA TYPE EXAMPLE PROGRAM FOR Visual Fortran
C
	PROGRAM CHAREXMP
	CHARACTER C, ALPHABET*26

	DATA ALPHABET/'ABCDEFGHIJKLMNOPQRSTUVWXYZ'/

	WRITE(6,99)
99      FORMAT('1 CHARACTER EXAMPLE PROGRAM OUTPUT'/)

	DO 100 I=1,26
	
	WRITE(6,10) ALPHABET
10      FORMAT(1X, A)

	ALPHABET = ALPHABET(2:) // ALPHABET(1:1)

100     CONTINUE

	CALL REVERSE(ALPHABET)
	WRITE(6,10) ALPHABET

	CALL REVERSE(ALPHABET(1:13))
	WRITE(6,10) ALPHABET

	CALL FINDSUBS('UVW', ALPHABET)
	CALL FINDSUBS('A', 'DAJHDHAJDAHDJA4E CEUEBCUEIAWSAWQLQ')

	WRITE(6,98)
98      FORMAT('0 END OF CHARACTER EXAMPLE PROGRAM OUTPUT')

	STOP
	END
C
	SUBROUTINE REVERSE(S)
	CHARACTER T, S*(*)

	J = LEN(S)
	IF (J .GT. 1) THEN
	    DO 10 I=1, J/2
		T = S(I:I)
		S(I:I) = S(J:J)
		S(J:J) = T
		J = J-1
10              CONTINUE
	    ENDIF

	RETURN
	END
C
	SUBROUTINE FINDSUBS(SUB, S)
	CHARACTER*(*) SUB,S
	CHARACTER*132 MARKS

	I = 1
	K = 1
	MARKS = ' '

10      J = INDEX(S(I:), SUB)
	IF (J .NE. 0) THEN
	    I = I + (J-1)
	    MARKS(I:I) = '#'
	    K = I
	    I = I+1
	    IF (I .LE. LEN(S)) GO TO 10
	    ENDIF

	WRITE(6,100) S, MARKS(:K)
100     FORMAT( 2(/1X, A) )
	END
