	SUBROUTINE LOOKUP()

C	LOOK UP THE OLD STATEMENT LABEL AND COMPUTE NEW LABEL.

	INCLUDE    'X:RESINC.FOR'

	CHARACTER  JX

C	DETERMINE # OF DIGITS IN OLD LABEL AND CONVERT TO INTEGER

	CALL STMLEN(STMENT,SLEN)

	DO 10 JA= J,SLEN	! Start search for label at column J.

	JX= STMENT(JA:JA)

	IF ((JX .GE. 'A' .AND. JX .LE. 'Z') .OR. (JX .GE. 'a' .AND.
	1 JX .LE. 'z') .OR.  JX .EQ. ')' .OR. JX .EQ. '*')   RETURN

	IF (JX .GE. 'A' .OR. JX .EQ. ')' .OR. JX .EQ. '*')   RETURN

	IF (JX .GE. '0' .AND. JX .LE. '9')  GOTO 20

10	CONTINUE

	RETURN

20	DO 30 KD= JA,SLEN	! JA= 1st digit of label.

	JX= STMENT(KD:KD)	! KD-1= last digit of label.

	IF (JX .LT. '0' .OR. JX .GT. '9')  GOTO 40

30	CONTINUE

40	NOL= KD-JA		! # OF DIGITS IN OLD LABEL.

C	FIND POSITION OF OLD LABEL IN ARRAY LABEL().

	READ(STMENT(JA:KD-1),'(I)')  N		! CHARACTER -> INTEGER.

	DO 50 I= 1,LAB

	IF (LABEL(I) .EQ. N)  GOTO 60

50	CONTINUE

C	LABEL NOT FOUND.   TAG "0000" (sore thumb).

	TEMP= ' 0000'

	NNL= 4

	K= 2

	GOTO 90

60	N= (I)*INCREM+ISTART		! CALCULATE NEW LABEL.

	WRITE(TEMP,'(I5)')  N		! INTEGER -> ASCII.

	DO 70 K= 1,5

	IF (TEMP(K:K) .NE. ' ')  GOTO 80

70	CONTINUE

80	NNL= 6-K			! # OF DIGITS IN NEW LABEL.

90	IF (NOL .EQ. NNL)  THEN

	STMENT(JA:KD-1)= TEMP(K:5)

	ELSE

	STMENT(JA+NNL:)= STMENT(KD:)

	STMENT(JA:JA+NNL-1)= TEMP(K:5)

	ENDIF

100	RETURN

	END
