CDECK  ID>, QTCHID.
      SUBROUTINE QTCHID (KBIT,LARG,OPTION,IDS)

C-    MARK DATA-STRUCTURE,  USER CALLED

      PARAMETER      (NQFNAE=2, NQFNAD=1, NQFNAU=3)
      PARAMETER      (IQFSTR=19, NQFSTR=6,  IQFSYS=25, NQFSYS=8)
      COMMON /MQCF/  NQNAME,NQNAMD,NQNAMU, IQSTRU,NQSTRU, IQSYSB,NQSYSB
      COMMON /MQCMOV/NQSYSS
      COMMON /MQCM/         NQSYSR,NQSYSL,NQLINK,LQWORG,LQWORK,LQTOL
     +,              LQSTA,LQEND,LQFIX,NQMAX, NQRESV,NQMEM,LQADR,LQADR2
      COMMON /MQCT/  IQTBIT,IQTVAL,LQTA,LQTB,LQTE,LQMTB,LQMTE,LQMTH
     +,              IQPART,NQFREE
      COMMON /QCN/   IQLS,IQID,IQNL,IQNS,IQND,IQFOUL
      COMMON /QSTATE/QVERSN,NQINIT,NQSTAG(2),NQPHAS,NQERR,QDEBUG,NQDCUT
     +,              NQNEWB,NQAFTB,NQM99,NQLOWB,NQWCUT,NQLOCK,QSTDUM
     +,              NQAUGM(2),NQZIP(8),AQMEM(12)
                         INTEGER QDEBUG
      PARAMETER      (IQBDRO=25, IQBMAR=26, IQBCRI=27, IQBSYS=31)
      COMMON /QBITS/ IQDROP,IQMARK,IQCRIT,IQZIM,IQZIP,IQSYS
                         DIMENSION    IQUEST(30)
                         DIMENSION                 LQ(99), IQ(99), Q(99)
                         EQUIVALENCE (QUEST,IQUEST),    (LQUSER,LQ,IQ,Q)
      COMMON //      QUEST(30),LQUSER(7),LQMAIN,LQSYS(24),LQPRIV(7)
     +,              LQ1,LQ2,LQ3,LQ4,LQ5,LQ6,LQ7,LQSV,LQAN,LQDW,LQUP
C--------------    END CDE                             -----------------  ------
      DIMENSION    KBIT(9),LARG(9),OPTION(9),IDS(9)
      EQUIVALENCE (JSTART,LQTA)
      EQUIVALENCE (JHORIZ,LQTB)
      EQUIVALENCE (JMINUS,LQTE)



      IQTBIT= KBIT(1)
      LCUR  = LARG(1)
      IF (LCUR.EQ.0)     RETURN

      NIDS  = IDS(1)
      CALL UOPT (OPTION,4HZSH-,IQTVAL,4)
      IQTVAL= 1 - IQTVAL
C     IF (IQTVAL.EQ.0)  IQTVAL=0                                         UNI
      LOLD  = 0
      L     = LCUR - 2 + JHORIZ
      LAST  = LCUR - JBYT (IQ(LCUR),IQSTRU,NQSTRU)

C------            LOOK AT NEXT LINK

   44 IF (L.LT.LAST)  GO TO 51
      LNEW= LQ(L)
      L   = L-1
      IF (LNEW.EQ.0)  GO TO 44

      IQNS = JBYT (IQ(LNEW),IQSTRU,NQSTRU)
      IF (IQNS.EQ.0)                   GO TO 53
      IF (JBYT(IQ(LNEW-1),25,8).NE.0)  GO TO 44
      IF (LNEW.EQ.LCUR)                GO TO 44

C--                NEW BANK LNEW REACHED, PUSH DOWN

      LQ(L+1)= LOLD
      CALL SBYT (LCUR-L,IQ(LCUR-1),25,8)
      LOLD= LCUR
      LCUR= LNEW
      L   = LCUR - 1
      LAST= LCUR - IQNS
      GO TO 44

C----              BANK LCUR HAS NO FURTHER SECONDARIES, POP UP

   51 IF (LOLD.EQ.0)  GO TO 81
      LNEW= LCUR
      LCUR= LOLD
      L   = LCUR - JRSBYT (0,IQ(LCUR-1),25,8)
      LOLD= LQ(L+1)
      LQ(L+1)= LNEW
      LAST= LCUR - JBYT (IQ(LCUR),IQSTRU,NQSTRU)

C--                BANK  LNEW  TO BE MARKED

   53 CALL QNAME (LNEW,IQID)
      N   =  MIN (1,IUCOMP(IQID,IDS(2),NIDS))
      IF (JMINUS-N.EQ.0)  GO TO 44
      CALL SBIT (IQTVAL,IQ(LNEW),IQTBIT)
      GO TO 44


C----              FINISHED, MARK THE START BANK

   81 CONTINUE
      IF (JSTART.NE.0)  CALL SBIT (IQTVAL,IQ(LCUR),IQTBIT)
      RETURN
      END
