C******************** START FILE URWORD.FOR ; GROUP URDUTS ******************
C---------------------------------------------------------------
C& URWORD FIND THE LIMITS OF A "WORD" FOR UREAD INPUT
C
      SUBROUTINE URWORD(STR,iup,LENW,LENR)
C
      CHARACTER*(*) STR
C
C  COMMAS AND/OR BLANKS DELIMIT WORDS
C   STR - INPUT STRING WITH WORD LEFT JUSTIFIED
C   IUP -  =1: convert unquoted lowercase letters to uppercase
C          =0: do not convert
C   LENW - OUTPUT LOCATION OF LAST CHARACTER OF WORD
C   LENR - OUTPUT LOCATION OF LAST CHARACTER PRECEDING
C     WORD AFTER LEFTMOST WORD (IF ANY), OR LENGTH OF INPUT
C     STRING.
C
C  SAMPLE INPUT:  "123456 GO"
C                       ^^
C             LENW______||_____LENR
C
C  LENR IS SUITABLE FOR CALL UROTOR ARGUMENT IF INPUT IS UREAD
C  TYPEAHEAD BUFFER.
C
C  LENW IS SUITABLE EG AS AN ARGUMENT FOR INTEGER OR FLOATING PT
C  DECODER ROUTINE
C
C  MOD DMC JAN 1988-- STRINGS IN DBL QUOTES ARE PASSED AS WORDS
C   CONTAINING IMBEDDED BLANKS, COMMAS, ETC.
C
C--------------------
C  REV DMC APR 1988
C  THE NEXT WORD STARTS AT THE FIRST NONBLANK CHARACTER AFTER THE
C  CURRENT WORD.  THE ONLY EXCEPTION IS THAT A COMMA "," IMMEDIATELY
C  FOLLOWING THE CURRENT WORD IS INTERPRETED AS ONLY BEING THE
C  DELIMITER FOR THE CURRENT WORD.
C
C  "12345, ZORK"
C       ^  ^             1 - END CURRENT WORD
C       1  2             2 - START NEXT WORD
C
C  "12345 , ZORK"
C       ^ ^
C       1 2
C
C  (PREVIOUSLY, THE COMMA IN THIS LAST EXAMPLE WOULD HAVE BEEN IGNORED)
C
C-------------
C  REV DMC FEB 1989
C  USER DEFINED PUNCTUATION INSTALLED.  IF USER SETS "," AND ";" AS
C  USER DEFINED PUNCTUATION, THEN, THE APPLICATION SEES THE FOLLOWING
C  AS START ADDRESSES OF (GENERALIZED) WORDS:
C
C  "12345, A,; B"
C   ^    ^ ^^^ ^
C   1    2 345 6
C
C  PUNCTUATION ITEMS ARE SEEN AS WORD STRINGS BY THE APPLICATION AND
C  MUST BE PROCESSED AT THE APPLICATIONS LEVEL.
C
C--------------------
C  EXECUTABLE CODE:
C
C  CHECK FOR INITIAL DBL QUOTE -- 2 CONSECUTIVE DBL QUOTES DO
C  NOT COUNT AS DELIMITERS
C
      ILEN=LEN(STR)
C
      CALL UWORDL(STR,-iup,IDUM,LENW,ICODE)
C
      IF(LENW.EQ.ILEN) THEN
        LENR=LENW
        GO TO 500
      ENDIF
C
      INEX=LENW+1
      IF(ICODE.EQ.2) THEN     ! TRAILING COMMA (OLD UREAD MEANING)
        IF(INEX.EQ.ILEN) THEN
          LENR=LENW
          GO TO 500
        ENDIF
        INEX=INEX+1
      ENDIF
C
      DO 10 ID=INEX,ILEN
        IF(STR(ID:ID).NE.' ') GO TO 20
 10   CONTINUE
C
      LENR=ILEN
      GO TO 500
C
 20   CONTINUE
      LENR=ID-1
C
 500  CONTINUE
C
      RETURN
C
      END
C******************** END FILE URWORD.FOR ; GROUP URDUTS ******************
