C******************** START FILE UPSSUB.FOR ; GROUP USPARM *************
C===============================================================
C  USPARM   LIBRARY OF SUBROUTINES FOR DEALING WITH 10 CHAR.
C           "STRING" PARAMETERS FOR USE WITH INDIRECT INPUT FILES
C           USED WITH "UREAD.FOR".  EACH PARAMETER IS IDENTIFIED
C           BY SPECIAL CHARACTER "/" FOLLOWED BY UP TO 10
C           ALPHANUMERIC CHARACTERS; EACH PARAMETER HAS A "VALUE"
C           OF UP TO 96 ASCII CHARACTERS; NULL STRING AND LEADING
C           BLANKS NOT ALLOWED
C  REV 10 AUG 81 D. MC CUNE.  MAX OF 96 CHARS IN PARAMETER VALUES
C   NOW SUPPORTED
C
C   EXAMPLE OF USAGE:
C
C   @ZFILE.TMI/NSHOT=12345/NRUN=9876
C
C   OPENS THE FILE "ZFILE.TMI" FOR INDIRECT INPUT, AND ASSOCIATES
C   THE VALUE "12345     " WITH PARAMETER "NSHOT     ", AND
C   "9876      " WITH PARAMETER "NRUN      ".
C
C   WHEN THE LINE
C
C   /NSHOT
C
C   IS ENCOUNTERED IN "ZFILE.TMI" THE SLASH & PARAMETER NAME
C   COMBINATION IS REPLACED BY THE PARAMETER VALUE STRING, AND
C   IT IS THIS VALUE WHICH IS PARSED AS INPUT TO THE MAIN CODE
C   WHICH IS USING "UREAD.FOR" AS INTERACTIVE I/O MANAGER.
C
C  FORMATS:
C   /(NAME)=(VALUE)    :  LOCAL VARIABLE ASSIGNMENT
C                    PARAMETER RECOGNIZED ONLY WHEN INPUT IS FROM
C                    SAME LEVEL (FILE) WHERE PARAMETER WAS DEFINED.
C   /(NAME)==(VALUE)   :  GLOBAL PARAMETER ASSIGNMENT
C                    PARAMETER RECOGNIZED UNTIL EXPLICITLY
C                    DELETED
C   /(NAME)=$DEL       :  DELETE SPECIFIED PARAMETER
C   /$DEL              :  DELETE ALL PARAMETERS (LOCAL + GLOBAL)
C   /$LIS              :  LIST ALL PARAMETERS (LOCAL + GLOBAL)
C
C   /(NAME)            :  FETCH NAMED PARAMETER'S VALUE AND
C                    INSERT INTO INPUT STREAM AT THIS POINT
C
C  D. MC CUNE DECEMBER 11 1980
C
C  AT THIS TIME, ALL PARAMETER REFERENCES OR DEFINITIONS MUST
C  BE INITIATED WITH THE "/" CHARACTER IN THE FIRST CHARACTER
C  POSITION OF AN INPUT LINE, OR DIRECTLY AFTER AN INDIRECT INPUT
C  FILENAME AS IN THE EXAMPLE "@ZFILE" ABOVE.
C
C  REVISIONS:
C    PASSING OF LOCAL PARAMETERS THROUGH INDIRECT INPUT FILE
C    LEVELS SUPPORTED; INVOKED BY FORMAT:
C
C   @ZFILE/PARM1/PARM2/PARM3=VALUE
C
C    IF "ZFILE" IS SUCCESSFULLY OPENED, PARM1 AND PARM2'S VALUES
C   ARE PASSED TO ZFILE'S LEVEL FOR USE THERE AS LOCAL PARAMETERS
C   PARM3'S VALUE IS DEFINED IN LINE AS ABOVE.  IF THE VALUE OF
C   A PARAMETER IS NOT KNOWN OR ASSIGNED IN-LINE, THE TOP-LEVEL
C   (USER OR BATCH CONTROL FILE) IS PROMPTED TO PROVIDE THE
C   MISSING PARAMETER VALUE.
C    PASSED PARAMETERS HANDLED SUBROUTINE "UPPASS"
C
C
C
C==============================================================
C&  UPSSUB   SUBSTITUTE STRING VALUE FOR SPECIFIED UREAD PARAMETER NAME
C
C            THIS ROUTINE CALLED WHEN "/(NAME) (CR)" FORMAT
C    IS DETECTED.   CHECK FOR "/$DEL" FORMAT REQUEST TO DELETE
C    ALL PARAMETERS
C
      SUBROUTINE UPSSUB(ZLINE,LLINE,IFLAG,ZVAL)
C
      USE USERIO
C
      CHARACTER*1 ZLINE(LLINE),ZC1,ZC2,ZBLANK
      CHARACTER*1 ZZLINE(132)
      CHARACTER*16 ZNAME
      CHARACTER*96 ZVAL
      CHARACTER*4 ZTES,ZDEL,ZLIS
      EQUIVALENCE(ZTES,ZNAME)
      DATA ZDEL/'$DEL'/
      DATA ZLIS/'$LIS'/
      DATA ZBLANK/' '/
C
      IFLAG=0
      IND1=2
      IND2=LLINE
      CALL USPLNM(ZLINE,LLINE,IND1,IND2,ZNAME,IER)
      IF(IER.NE.0) GO TO 500
C  CHECK FOR DELETION ORDER
      IF(ZTES.NE.ZDEL) GO TO 50
C  DELETE ALL SYMBOLS
      CALL USPCLR
      GO TO 500
C  NOT A DELETE; CHECK FOR RECOGNITION OF NAME
 50   CONTINUE
C  CHECK FOR LISTING REQUEST
      IF(ZTES.NE.ZLIS) GO TO 52
      CALL UPDISP
      GO TO 500
 52   CONTINUE
      CALL USPGET(ZNAME,ZVAL,IER)
C  FOUND VALUE ?
      IF(IER.EQ.0) GO TO 100
C  NO.  PROMPT USER; IN BATCH READ FROM TOP LEVEL (COMMAND FILE)
C       AND EXPECT ANSWER IN FORM "/=(VALUE)" OR HALT PROGRAM
C
      CALL UPQUER(ZNAME,ZZLINE,132,ZVAL)
      PRMSUB=ZNAME
      IFLAG=0
      RETURN
C------
C---------
C  NORMAL PATH:  PARAMETER SUCCESSFULLY TRANSLATED
C
 100  CONTINUE
      IFLAG=0
      PRMSUB=ZNAME
      RETURN
C---------
C  EXIT AFTER DELETION OF PARAMETERS ORDER
C
 500  CONTINUE
      IFLAG=1
C  TYPEAHEAD-- ROTATE OUT LIST/DELETE REQUEST
      CALL UROTOR(IND2)
      CALL UDECOD
C
      RETURN
      	END
C******************** END FILE UPSSUB.FOR ; GROUP USPARM ******************
