C
C SUBROUTINE 'TASKI'
C ==================
C
C Output a text prompt to the terminal with a default integer value
C (and log file if required). Read in and return an integer value.
C
C If the reply has invalid syntax then the prompt will be repeated
C
C (Max length for reply and value in prompt is 25 characters)
C
C Logging as for TPROMP and TREAD
C
C If possible do not output a carriage return or linefeed after the prompt.
C
      SUBROUTINE TASKI (STR, IVALUE, EOF)
C
C Parameters:
C
C      STR (I)   Character string for the question 
C                The default value will be appended as ' [value]: '
C   IVALUE (I/O) On input:  the default value
C                On output:  the value read in (nearest integer if a floating
C                            point number is given)
C      EOF (O)   Logical flag = .true. if end of file (or read error) 
C                encountered else .false.
C
C====== Specification statements
C
      CHARACTER*(*) STR
      INTEGER IVALUE
      INTEGER ND
      LOGICAL EOF, ERR
      CHARACTER*120 PROMPT
      CHARACTER*25 XSTR
      LOGICAL LOG
      COMMON /TTCOMN/ LUNR, LUNW, LUNLR, LUNLW, MODETT, LOG
      SAVE /TTCOMN/
C
C====== Get length less trailing blanks
C
      LL = LEN(STR)
      DO 100 L=LL,1,-1
         IF (STR(L:L).NE.' ') GO TO 120
100   CONTINUE
      L=1
C
C====== Write integer value to a string
C
120   WRITE (XSTR,'(I25)') IVALUE
C
C====== Form prompt string
C
      PROMPT = STR(1:L)//' ['
      L = L + 2
      DO 130 I=1,25
         IF (XSTR(I:I).NE.' ') THEN
            L = L + 1
            PROMPT(L:L) = XSTR(I:I)
         ENDIF
130   CONTINUE
      PROMPT(L+1:) =']: '
      L = L + 3
C
C====== Output prompt
C
200   CALL TPROMP (PROMPT(1:L))
C
C====== Get reply
C
      CALL TREAD (XSTR, EOF)
      IF (EOF) RETURN
      IF (XSTR.EQ.' ') RETURN
      X = FLPVAL(XSTR,ERR)
      IF (ERR) GO TO 200
      IVALUE = NINT(X)
      RETURN
      END
