C******************** START FILE UCMPPR.FOR ; GROUP UREAD5 ******************
C--------------------------------------------------------------
C&  UCMPPR COMPARE PROGRAM PROMPT WITH RECORD FROM INPUT FILE
C
C  COMPARE INPUT ";" CARD WITH PROMPT SENT TO UREAD CALLER FOR
C  A MATCH-- IF CARD MATCHES, THIS INDICATES THAT INDIRECT INPUT
C  FILE CONTROLLING THE MAIN PROGRAM IS IN LINE WITH PROGRAM PROMPTS.
C
C  IF A MATCH IS FOUND SET THE FLAG IREADY=1
C
      SUBROUTINE UCMPPR
C
      INCLUDE 'USERIO'
C
      CHARACTER*10 ZWORDA,ZWORDC
C
C  PROMPT IS IN COMMON ("ABUFF(1:NCHARA)")
C  FILE INPUT IS IN COMMON ("CBUFF")
C
C  APPLICATION CONTROLS WHAT WORD RANGE IN PROMPT TO CHECK
C  VIA COMMON ARRAY NCPRM WHICH IS SET BY "CALL URDPMA(I,J)"
C  E.G. "CALL URDPMA(1,3)" SAYS DEFINE PROMPTS TO MATCH IF THE
C  FIRST 3 WORDS AGREE
C
C  CALL URDPMA(2,4) SAYS CHECK WORDS 2--4 FOR MATCH
C
C  CALL URDPMA(0,0) WILL TURN OFF ALL PROMPT MATCH CHECKING FEATURES
C  SO WILL CALL URDPMA(2,1)
C
C  CF UREAD LOGICAL FUNCITON LCMPPR
C
C
C *LISMAK* 12-APR-88  GENERATED LOGICAL DECLARATIONS
      LOGICAL LCMPPR
C *LISMAK* END OF GENERATED LOGICAL DECLARATIONS
C
      IF(.NOT.LCMPPR(IW1,IW2)) GO TO 200
C
C---------------------------
C  INITIALIZE WORD SEARCH
C
      ISTARTA=1
      ISTARTC=INDEX(CBUFF,MSEMI)+1
C
      IENDA=NCHARA
C---------------
C  FIND LAST CHAR WHICH IS NEITHER BLANK NOR MDOLLR
C
      ILEN=LEN(CBUFF)
      INBLANK=0
      DO 5 IC=ILEN,1,-1
        IF(CBUFF(IC:IC).NE.' ') INBLANK=1
        IF((INBLANK.EQ.1).AND.(CBUFF(IC:IC).NE.MDOLLR))
     >      GO TO 6
 5    CONTINUE
      IC=0
 6    CONTINUE
C
      IENDC=IC
      IF(IENDC.LE.0) GO TO 300
C
      IWORD=0
C
      ISTA=ISTARTA-1
      ISTC=ISTARTC-1
C
 10   CONTINUE
      IWORD=IWORD+1
      IF(IWORD.GT.IW2) GO TO 200  ! MATCH ENOUGH WORDS YET?
C
      CALL UWORDL(ABUFF(1:IENDA),ISTA,I1A,I2A,ICODA)
      CALL UWORDL(CBUFF(1:IENDC),ISTC,I1C,I2C,ICODC)
C
      IAMIN=MIN0(I1A,I2A)
      ICMIN=MIN0(I1C,I2C)
C
      IF((ICODA.EQ.0).AND.(ICODC.EQ.0)) GO TO 200  ! SIMULTANEOUS END?
C
      IF((IAMIN.EQ.0).AND.(ICMIN.EQ.0)) GO TO 10   ! SIMULTANEOUS NULL
C
C  CHECK *THIS* WORD?
      IF(IWORD.LT.IW1) GO TO 20
C
      ZWORDA='          '
      IF(I2A.GE.MAX0(1,I1A)) THEN
        ILA=MIN0(10,(I2A-I1A+1))
        ZWORDA(1:ILA)=ABUFF(I1A:I1A+ILA-1)
        CALL USPCAP(ZWORDA)
      ENDIF
C
      ZWORDC='          '
      IF(I2C.GE.MAX0(1,I1C)) THEN
        ILC=MIN0(10,(I2C-I1C+1))
        ZWORDC(1:ILC)=CBUFF(I1C:I1C+ILC-1)
        CALL USPCAP(ZWORDC)
      ENDIF
C
      IF(ZWORDA.NE.ZWORDC) GO TO 300
C
 20   CONTINUE
      ISTA=MAX0(I1A,I2A)
      ISTC=MAX0(I1C,I2C)
      GO TO 10
C---------------------------
C  MATCH
 200  CONTINUE
      CALL UREADY(1)
      IF(NLSKIP.AND.(NLECHO.OR.(LPMMSG.EQ.1).OR.(IBATCH.EQ.1)))
     >     WRITE(LUNTRM,3200) NCMND(NLUNIN)
 3200 FORMAT(' PROMPT MATCH FOUND - CONTROL RESUMED AT RECORD ',I4)
      NLSKIP=.FALSE.
C---------------------------
C  EXIT (E.G. NO MATCH)
C
 300  CONTINUE
      RETURN
      END
C******************** END FILE UCMPPR.FOR ; GROUP UREAD5 ******************
