      INTEGER FUNCTION LENBA(TEXT,LENGTH)
      IMPLICIT INTEGER (A-Z)
C
C Author       : Kevin Black
C Date written : 06 August 1985
C Edited       : August 1987 for MS-DOS/IBM-PC
C                December 1987, for ADVENTURE
C Abstract     :
C
C Integer function to return the length of a string TEXT which is
C of length LENGTH and is system null terminated. i.e. the routine
C returns the position of the last non blank character in TEXT.
C 
C
      CHARACTER*(*) TEXT
      IF(LENGTH.GT.0)THEN
         DO 10 I=LENGTH,1,-1
         IF(TEXT(I:I).NE.' ')THEN
            LENBA=I
            RETURN
         ENDIF
10       CONTINUE
      ENDIF
      LENBA=0
      RETURN
      END
