Trailing-Edge
-
PDP-10 Archives
-
decus_20tap5_198111
-
decus/20-0141/getwrd.for
There are 2 other files named getwrd.for in the archive. Click here to see a list.
SUBROUTINE GETWRD(IPACKD,IBUFFR,MAXBFR,LOWBFR,KIND )
C RENBR(/GET NEXT WORD IN SINGLE LINE)
C
C DONALD BARTH, HARVARD BUSINESS SCHOOL
C
C ROUTINE TAKING AS INPUT LIST OF POSSIBLE WORDS
C SUPPLIED IN MULTIPLE OF A5 FORMAT, AND MATCHES NEXT
C WORD IN LINE OF TEXT READ WITH MULTIPLE OF A1 FORMAT
C
C IPACKD = STRING OF WORDS SIMILAR TO '/YES NO/'
C WHERE INITIAL CHARACTER WITHIN STRING
C (HERE SLASH) ALSO MARKS END OF STRING.
C STRING CAN CONTAIN AT MOST 20 WORDS FORMED
C FROM TOTAL OF NO MORE THAN 100 CHARACTERS.
C IBUFFR = TEXT TYPED BY USER READ BY MULTIPLE OF A1
C FORMAT
C MAXBFR = NUMBER OF CHARACTERS IN IBUFFR
C LOWBFR = INITIALLY SHOULD BE INPUT CONTAINING ZERO
C TO ALLOW INITIAL COMMA TO INDICATE MISSING
C ITEM. THEREAFTER SHOULD BE INPUT CONTAINING
C SUBSCRIPT OF NEXT LOCATION IN IBUFFR ARRAY
C WHICH IS TO BE EXAMINED.
C = RETURNED POINTING TO NEXT CHARACTER NOT YET
C EXAMINED.
C KIND = SEQUENCE NUMBER OF MATCHED WORD PLUS 3.
C = 1, LINE IS EMPTY
C = 2, ERROR MESSAGE TYPE TO USER
C = 3, MISSING ITEM INDICATED BY EXTRA COMMA
C
DIMENSION IPACKD(100),IBUFFR(MAXBFR),KNTLTR(20),
1IWORD(100)
DATA ITTY,LMTWRD,LMTKNT/5,100,20/
DATA IWHAT/1H?/
C
C CONSTRUCT A1 FORMAT DICTIONARY
MAXWRD=0
MAXKNT=0
CALL A5TOA1(IPACKD,100,LMTWRD,LMTKNT,MAXWRD,MAXKNT,
1IWORD,KNTLTR)
C
C MATCH USER TYPED TEXT AGAINST A1 FORMAT DICTIONARY
MANY=1
IF(LOWBFR.GT.0)GO TO 1
LOWBFR=1
MANY=0
1 LOCK=MANY
CALL DALOSS(1,MAXWRD,IWORD,1,MAXKNT,
1KNTLTR,IBUFFR,MAXBFR,LOWBFR,KIND,MATCH,LCNWRD,
2LCNKNT,LCNBFR,MANY,LCNERR)
GO TO(5,6,12,12,6,6,6,6,2,4,11),KIND
C
C TREAT SEMICOLON LIKE COMMA
2 IF(LOCK.EQ.0)GO TO 3
MANY=-1
GO TO 1
3 LOWBFR=LOWBFR-1
GO TO 11
C
C BUFFER IS EMPTY
4 IF(MANY.LT.0)GO TO 11
5 KIND=1
GO TO 13
C
C UNKNOWN INITIAL CHARACTER
6 LOWBFR=LCNERR
LCNERR=LCNERR-1
KIND=2
WRITE(ITTY,7)IWHAT,(IBUFFR(I),I=LCNBFR,LCNERR),IWHAT
7 FORMAT(' ILLEGAL RESPONSE ',132A1)
WRITE(ITTY,8)
8 FORMAT(' RESPOND WITH ONE OF FOLLOWING')
LTREND=0
KNTEND=0
9 KNTEND=KNTEND+1
IF(KNTEND.GT.MAXKNT)GO TO 13
LTRBGN=LTREND+1
LTREND=LTREND+KNTLTR(KNTEND)
WRITE(ITTY,10)(IWORD(I),I=LTRBGN,LTREND)
10 FORMAT(3X,132A1)
GO TO 9
C
C MISSING WORD
11 KIND=3
GO TO 13
C
C CORRECT MATCH FOUND
12 KIND=MATCH+3
C
C RETURN TO CALLING PROGRAM
13 RETURN
C377634367196?'
END