
   INTEGER FUNCTION VOCABX(ID,INIT)
      USE ALLCOM

!     LOOK UP ID IN THE VOCABULARY (ATAB) AND RETURN ITS "DEFINITION" (VOCABX -1 IF NOT FOUND). IF INIT IS POSITIVE, THIS IS AN
!     INITIALISATION. CALL UP A KEYWORD VARIABLE, AND NOT FINDING IT CONSTITUTES A BUG.  ONLY KTAB VALUES WHICH TAKEN OVER 1000
!     EQUAL INIT MAY BE CONSIDERED (THUS "STEPS", WHICH IS A MOTION VERB AS WELL AS AN OBJECT, MAY BE LOOKED AS AN OBJECT.)
 
      INTEGER INIT,WDCLAS,I,CLASS
      CHARACTER(6) ID,MSG*36

      WDCLAS=INIT
      IF (INIT.LT.0) WDCLAS=-INIT-1
       
      DO I=1,TABSIZ
         IF (KTAB(I).EQ.-1) GO TO 2
         IF (ATAB(I).NE.ID) CYCLE
         IF (CLASS(KTAB(I)).GE.WDCLAS) GO TO 3
      END DO
      CALL BUG('RAN OFF END OF VOCABULARY TABLE')

2     VOCABX=-1
      IF (INIT.LT.0) RETURN
      WRITE(MSG,"(' CAN''T FIND ''',A,''' IN VOCAB TABLE')") ID
      CALL BUG(MSG)

3     VOCABX=KTAB(I)
      IF (INIT.GE.0) VOCABX=MOD(VOCABX,1000)
      END