C******************** START FILE URDCMI.FOR ; GROUP UREAD5 *************
C
C-------------------------------------------------------------------
C&  URDCMI   EXECUTE UREAD COMMAND (PROGRAM CALLABLE)
C
      SUBROUTINE URDCMI(ZSTR,IER)
C
      USE USERIO
C
      CHARACTER*(*) ZSTR	! COMMAND STRING
C
      CHARACTER*8 UCNTRL	! COMMAND CONTROL STRING
      CHARACTER*(urdbufl) ZCBUFF  ! TEMPORARY STORAGE FOR TYPEAHEAD BUFFER
C
      LOGICAL ILHOLD		! HOLD TYPEAHEAD SWITCH
C
C  SET COMMON SWITCH INDICATING PROGRAM REQUESTED COMMAND EXECUTION
      LCMDIN=2
C
C  CHECK INPUT LENGTH
      IL=LEN(ZSTR)
      IF((IL.LT.1).OR.(IL.GT.LBUFF)) THEN
        CALL UERMSI(
     >'?CALL URDCMI(commmand,istat) COMMAND STRING LENGTH ERROR',IL,1)
        IER=1
        RETURN
      ENDIF
C
C  SAVE TYPEAHEAD BUFFER
      ZCBUFF=CBUFF
C
C  INSERT COMMAND STRING IN TYPEAHEAD BUFFER
      CALL UCBCLR
      CBUFF(1:IL)=ZSTR
C
C  ENABLE MULTIPLE COMMANDS ON LINE
      ILHOLD=NLHOLD
      NLHOLD=.FALSE.
C
C  CHECK COMMAND - GENERATE CONTROL STRING - MULTICOMMAND LOOP
 10   CONTINUE
      CALL URCSTR(UCNTRL)
C
C  WHICH COMMAND?
      CALL UDECOD
      ICMD=JXUOPC(UCNTRL,DBUFF(1))
C
      IF(ICMD.EQ.0) THEN
        CALL UERMSG(
     >' ? CALL URDCMI(command,istat) ERROR:  INVALID COMMAND',ZSTR,1)
        IER=1
        RETURN
      ENDIF
C
C  EXECUTE COMMAND
C
      CALL URDSPC(ICMD,IRET,IDUM,IER)
C
      IF(IER.NE.0) THEN
        CALL UERMSG(
     >' ? CALL URDCMI(command,istat) DETECTED ERROR, COMMAND:',ZSTR,1)
        NLHOLD=ILHOLD
        RETURN
      ELSE IF(IRET.EQ.3) THEN
        CALL UERMSG(
     >' ? CALL URDCMI(command,istat) INVALID "*" COMMAND:',ZSTR,1)
        NLHOLD=ILHOLD
        RETURN
      ENDIF
C
C  COMMAND MORE COMMANDS?
C
      IF(NCHARC.GT.0) GO TO 10
C
C  RESTORE TYPEAHEAD BUFFER
C
      NLHOLD=ILHOLD
      CBUFF=ZCBUFF
      CALL UDECOD
C  RECHECK OUTPUT FLAG
      CALL URXOUT
C
      IF(NLECHO.AND.(IER.EQ.0)) WRITE(LUNTRM,3001) ZSTR
 3001 FORMAT(
     >' % COMMAND(S) EXECUTED BY CALL URDCMI, INPUT STRING:'/1X,A)
C
      RETURN
      END
C******************** END FILE URDCMI.FOR ; GROUP UREAD5 ***************
