C***********************************************************************
C
C  THIS SUBROUTINE PICKS UP THE TAG (ITAGS) OF AN ITEM DISPLAYED ON THE
C  SCREEN WHICH HAS BEEN POINTED TO BY THE USER (USING THE LIGHT PEN).
C  IF LL.LE.ITAGS.LE.LU, OR ITAGS.EQ.LR, ITAGS IS RETURNED NORMALLY.
C  IF NEITHER OF THE ABOVE IS TRUE, AN ERROR MESSAGE IS DISPLAYED ALONG
C  WITH INSTRUCTIONS AS TO WHAT SHOULD HAVE BEEN ENTERED.
C
C***********************************************************************
      FUNCTION ITAGS(LL,LU,LR,I)
C                                            ARGUMENT I REFERS TO THE
C                                            INSTRUCTIONS TO BE GIVEN IF
C                                            THERE IS AN ERROR.
      LOGICAL LP,BINT
      COMMON /SPEN/NUM,IX,IY,BINT,LP,IT
C                                            MENU INCAM3 CONTAINS ERROR
C                                            MESSAGE.  MENU INCAM6
C                                            CONTAINS INSTRUCTIONS.
      DATA A,B/5HINCAM,4H6BIN/
      DATA C/4H3BIN/
C                                            SET UP INTERRUPT VARIABLES.
      CALL SETPEN(IT,LP,IX,IY)
      CALL BOX(NUM,BINT)
C                                            WAIT FOR BUTTON TO BE
C                                            PRESSED
    2 LP=.FALSE.
      NUM=-1
    5 IF(NUM.EQ.-1)GO TO 5
C                                            THEN PICK UP TAG.
    1 IF(.NOT.LP)GO TO 1
C                                            TEST FOR TAG IN RANGE.
      IF((IT.LT.LL.OR.IT.GT.LU).AND.IT.NE.LR)GO TO 3
C                                            IF SO RETURN.
      ITAGS=IT
      RETURN
C                                            IF NOT, THERE HAS BEEN
C                                            AN ENTRY ERROR.
C                                            READ IN MENUS.
    3 CALL MENCRT(A,B,-1)
      CALL MENCRT(A,C,-1)
C                                            DISPLAY INSTRUCTIONS.
      CALL MENCRT(A,B,I)
C                                            ALSO, FLASH ERROR MESSAGE.
      BINT=.FALSE.
    4 CALL MENCRT(A,C,1)
      CALL MENCRT(A,C,0)
      IF(.NOT.BINT)GO TO 4
C                                            USER HAS NOW READ DISPLAY,
C                                            SO SWITCH IT OFF AND
C                                            GIVE HIM ANOTHER TRY.
      CALL MENCRT(A,B,-2)
      CALL MENCRT(A,C,-2)
      GO TO 2
      END
