      SUBROUTINE RNOASK(MASTER,ITTY,JTTY,IDISK,JDISK,NDISK,
     1JOFFST,ITRMNL,JTRMNL,IRANGE,JRANGE,KRANGE)
C     RENBR(/GET FILE NAMES AND OPEN THEM)
C
C     DONALD E. BARTH, YALE SCHOOL OF MANAGEMENT
C
C     *****************************************************
C     *                                                   *
C     *  THIS VERSION OF THE FILES RNOASK AND RNOCMN  IS  *
C     *  DESIGNED  FOR  USE  ON  THE DECSYSTEM-10.  THIS  *
C     *  VERSION OF THESE ROUTINES MERELY READS THE FILE  *
C     *  NAMES  INTO  DOUBLE  PRECISION  WORDS WHICH ARE  *
C     *  USED DIRECTLY IN  THE  OPEN  STATEMENTS.   THIS  *
C     *  VERSION  OF  THESE  ROUTINES  SHOULD BE EASY TO  *
C     *  CONVERT    TO    OTHER    COMPUTER     SYSTEMS.  *
C     *  DECSYSTEM-10  FILE  NAMES  CONSIST  OF  UP TO 6  *
C     *  LETTERS OR DIGITS, FOLLOWED  BY  A  PERIOD  AND  *
C     *  THEN  BY  UP  TO 3 LETTERS OR DIGITS.  A LONGER  *
C     *  VERSION OF THESE ROUTINES  IS  AVAILABLE  WHICH  *
C     *  SUPPLIES  DEFAULTS FOR THE FILE NAMES WHICH ARE  *
C     *  NOT SPECIFIED BY THE USER.                       *
C     *                                                   *
C     *****************************************************
C
C     MASTER = 0 ON INPUT, FIRST  TIME  THAT  THE  USER  IS
C              BEING  ASKED  TO  SPECIFY  FILES.   USER  IS
C              REQUIRED TO SPECIFY INPUT FILE.   MASTER  IS
C              RETURNED UNCHANGED BY THIS PROGRAM.
C            = 1 ON INPUT,  SECOND OR SUBSEQUENT TIME  THAT
C              USER IS BEING ASKED TO SPECIFY FILES.  IF NO
C              INPUT FILE  IS  SPECIFIED,  THEN  MASTER  IS
C              RETURNED  UNCHANGED  AND  EXIT IS ASSUMED BY
C              MAIN PROGRAM.  IF INPUT FILE  IS  SPECIFIED,
C              THEN MASTER IS RETURNED SET TO -1.
C            = 2 ON INPUT,  USER IS TO  BE ASKED TO SPECIFY
C              SPLICE FILE.   MASTER IS RETURNED UNCHANGED,
C              SINCE A NULL ANSWER IS NOT ALLOWED.
C            = 3 ON INPUT,  ALL OF THE PREVIOUSLY SPECIFIED
C              SOURCE  FILE  HAS  BEEN READ.  THE USER CAN,
C              BUT NEED NOT,  SPECIFY  AN  ADDITIONAL  FILE
C              WHICH  IS  TO  CONTINUE  THE  TEXT.   IF  AN
C              ADDITIONAL FILE IS SPECIFIED, THEN MASTER IS
C              RETURNED  SET  TO  -3.   MASTER  IS RETURNED
C              UNCHANGED  IF  THE  USER DOES NOT SPECIFY AN
C              ADDITIONAL FILE.
C     ITTY   = UNIT NUMBER FOR MESSAGES TO BE SEEN BY USER
C     JTTY   = UNIT NUMBER FROM WHICH USER RESPONSE IS READ
C     IDISK  = UNIT NUMBER FROM WHICH INPUT SOURCE FILE  IS
C              TO BE READ
C     JDISK  = UNIT  NUMBER  TO  WHICH OUTPUT FILE IS TO BE
C              WRITTEN
C     NDISK  = UNIT NUMBER FROM  WHICH SPLICE FILE IS TO BE
C              READ.
C     JOFFST = RETURNED  WITH OFFSET  TO BE APPLIED  TO THE
C              RESULTING   DOCUMENT  IN  ADDITION  TO  THAT
C              SPECIFIED IN THE SOURCE FILE.
C     ITRMNL = 0, RETURNED IF OUTPUT IS TO BE TO DISK FILE.
C            = 1, RETURNED IF  OUTPUT IS  TO BE TO TERMINAL
C              AND  FROFF IS TO  PAUSE AT TOP OF  EACH PAGE
C              FOR SEPARATE SHEETS  OF PAPER TO BE INSERTED
C              INTO THE TERMINAL.
C            = -1, RETURNED IF OUTPUT IS TO BE TO TERMINAL,
C              BUT  FROFF IS  NOT TO  PAUSE AT  TOP OF EACH
C              PAGE.
C     JTRMNL = 0, RETURNED IF ULTIMATE OUTPUT DEVICE CANNOT
C              DO HALF-LINE FEEDS.
C            = 1, RETURNED IF OUTPUT DEVICE USED FOR DRAFTS
C              CANNOT DO HALF-LINE FEEDS, BUT DOCUMENT WILL
C              ULTIMATELY  BE  PRODUCED  ON  OUTPUT  DEVICE
C              WHICH CAN DO HALF-LINE FEEDS.
C            = 2,   RETURNED  IF  OUTPUT  DEVICE   CAN   DO
C              HALF-LINE  FEEDS  TO POSITION LOWER ON PAGE,
C              BUT CANNOT THEN RETURN TO HIGHER POSITION.
C            = 3,   RETURNED  IF  OUTPUT  DEVICE   CAN   DO
C              HALF-LINE FEEDS IN BOTH DIRECTIONS.
C     IRANGE = SERIAL NUMBER OF FIRST PAGE TO BE SHOWN
C     JRANGE = SERIAL NUMBER OF LAST PAGE TO BE SHOWN
C     KRANGE = -1, ALREADY BEYOND REQUESTED PAGE RANGE
C            = 0 OR 1, STILL PRODUCING REQUESTED PAGES
C
      DIMENSION LTRABC(26),LWRABC(26),LTRDGT(10),LTRBFR(30)
      DOUBLE PRECISION NAMSRC,NAMOUT,NAMSPL,NAMNUL
C
C     MAXBFR = DIMENSION OF LTRBFRUSED TO INPUT OPTIONS
      DATA MAXBFR/30/
C
C     NAMNUL = NULL NAME
      DATA NAMNUL/10H          /
C
C     LTRSPC = SPACE
C     LTRTAB = TAB
C     LTRPLS = PLUS SIGN
C     LTRMNS = MINUS SIGN
C     LTRCLN = COLON
      DATA LTRSPC,LTRTAB,LTRPLS,LTRMNS,LTRCLN/
     11H ,"045004020100,1H-,1H+,1H:/
      DATA LTRABC /1HA,1HB,1HC,1HD,1HE,1HF,1HG,1HH,1HI,1HJ,
     1 1HK,1HL,1HM,1HN,1HO,1HP,1HQ,1HR,1HS,1HT,1HU,1HV,1HW,
     2 1HX,1HY,1HZ/
      DATA LWRABC /1Ha,1Hb,1Hc,1Hd,1He,1Hf,1Hg,1Hh,1Hi,1Hj,
     1 1Hk,1Hl,1Hm,1Hn,1Ho,1Hp,1Hq,1Hr,1Hs,1Ht,1Hu,1Hv,1Hw,
     2 1Hx,1Hy,1Hz/
      DATA LTRDGT /1H0,1H1,1H2,1H3,1H4,1H5,1H6,1H7,1H8,1H9/
C
C     CHECK IF SPLICE FILE IS TO BE OPENED
      IF(MASTER.EQ.2)GO TO 52
      IF(MASTER.EQ.3)GO TO 48
C
C     TELL USER THAT ARE DONE WITH PREVIOUS INPUT
      IF(MASTER.EQ.0)WRITE(ITTY,1)
    1 FORMAT(17H FROFF (03/11/81))
      IF(MASTER.NE.0)WRITE(ITTY,2)
    2 FORMAT(1X/24H TYPE EMPTY LINE TO EXIT/1X)
      LPTTTY=0
      JOFFST=-1
C
C     OPEN INPUT FILE
    3 WRITE(ITTY,4)
    4 FORMAT(14H SOURCE FILE: ,$)
      READ(JTTY,5)NAMSRC
    5 FORMAT(1A10)
      IF(NAMSRC.NE.NAMNUL)GO TO 6
      IF(MASTER.NE.0)GO TO 58
      GO TO 9
    6 OPEN(UNIT=IDISK,FILE=NAMSRC,ACCESS=5HSEQIN,ERR=7)
      GO TO 11
    7 WRITE(ITTY,8)NAMSRC
    8 FORMAT(25H CANNOT READ SOURCE FILE ,1A10)
      GO TO 3
    9 WRITE(ITTY,10)
   10 FORMAT(30H SOURCE FILE MUST BE SPECIFIED)
      GO TO 3
C
C     ASK USER FOR NAME OF OUTPUT FILE
C     DELAY ITS OPENING UNTIL HAVE ASKED OPTIONS QUESTION
C     SINCE DON'T KNOW YET IF TO DISK OR TO TERMINAL
   11 WRITE(ITTY,12)
   12 FORMAT(14H OUTPUT FILE: ,$)
      READ(JTTY,5)NAMOUT
      IF(NAMOUT.EQ.NAMSRC)GO TO 46
      IF(NAMOUT.NE.NAMNUL)GO TO 14
      LPTTTY=-1
      WRITE(ITTY,13)
   13 FORMAT(24H TERMINAL OUTPUT ASSUMED)
   14 CONTINUE
C
C     *********************************
C     *                               *
C     *  ASK USER TO SPECIFY OPTIONS  *
C     *                               *
C     *********************************
C
   15 IF(JOFFST.GE.0)GO TO 42
   16 ITRMNL=LPTTTY
      IRANGE=0
      JRANGE=9999
      JOFFST=0
      WRITE(ITTY,17)
   17 FORMAT(24H OPTIONS (/H FOR HELP): ,$)
      READ(JTTY,18)(LTRBFR(I),I=1,MAXBFR)
   18 FORMAT(70A1)
C
C     INTERPRET OPTIONS
      INDEX=0
   19 INDEX=INDEX+1
   20 IF(INDEX.GT.MAXBFR)GO TO 42
      LTRNOW=LTRBFR(INDEX)
      IF(LTRNOW.EQ.LTRSPC)GO TO 19
      IF(LTRNOW.EQ.LTRTAB)GO TO 19
C
C     TEST LETTER TO DETERMINE WHAT OPTION IS DESIRED
   21 KNDFLG=0
   22 KNDFLG=KNDFLG+1
      IF(KNDFLG.GT.26)GO TO 19
      IF(LTRABC(KNDFLG).EQ.LTRNOW)GO TO 23
      IF(LWRABC(KNDFLG).NE.LTRNOW)GO TO 22
C     GO TO( A, B, C, D, E, F, G, H, I, J,
C    1       K, L, M, N, O, P, Q, R, S, T,
C    2       U, V, W, X, Y, Z),KNDFLG
   23 GO TO(31,24,30,31,25,31,31,26,31,31,
     1      31,31,31,31,27,28,31,31,31,29,
     2      31,30,31,31,31,31),KNDFLG
C
C     /BEGIN
   24 IRANGE=0
      GO TO 31
C
C     /END
   25 JRANGE=0
      GO TO 31
C
C     /HELP
   26 CALL RNOHLP(ITTY)
      GO TO 16
C
C     /OFFSET
   27 JOFFST=0
      GO TO 31
C
C     /PAUSE
   28 ITRMNL=1
      GO TO 31
C
C     /TERMINAL
   29 JTRMNL=0
      GO TO 31
C
C     /VIEW
   30 IF(ITRMNL.EQ.0)ITRMNL=-1
      GO TO 31
C
C     EVALUATE NUMBER TO RIGHT OF LETTER
   31 NUMFLG=0
      KNDNUM=0
   32 INDEX=INDEX+1
      IF(INDEX.GT.MAXBFR)GO TO 37
      LTRNOW=LTRBFR(INDEX)
      IF(LTRNOW.EQ.LTRSPC)GO TO 33
      IF(LTRNOW.NE.LTRTAB)GO TO 34
   33 IF(KNDNUM.LE.0)GO TO 32
      GO TO 37
   34 DO 36 L=1,10
      IF(LTRDGT(L).NE.LTRNOW)GO TO 36
      IF(KNDNUM.GT.1)GO TO 35
      KNDNUM=1
      NUMFLG=(10*NUMFLG)+L-1
      GO TO 32
   35 NUMFLG=(10*NUMFLG)-L+1
      GO TO 32
   36 CONTINUE
      IF(KNDNUM.GT.0)GO TO 37
      IF(LTRNOW.EQ.LTRPLS)KNDNUM=1
      IF(LTRNOW.EQ.LTRMNS)KNDNUM=2
      IF(KNDNUM.GT.0)GO TO 32
      IF(KNDNUM.NE.0)GO TO 37
      IF(LTRNOW.EQ.LTRCLN)KNDNUM=-1
      IF(KNDNUM.NE.0)GO TO 32
   37 INDEX=INDEX-1
      IF(NUMFLG.LT.0)NUMFLG=0
C     GO TO( A, B, C, D, E, F, G, H, I, J,
C    1       K, L, M, N, O, P, Q, R, S, T,
C    2       U, V, W, X, Y, Z),KNDFLG
      GO TO(19,38,19,19,39,19,19,19,19,19,
     1      19,19,19,19,40,19,19,19,19,41,
     2      19,19,19,19,19,19),KNDFLG
C
C     /BEGIN
   38 IRANGE=NUMFLG
      GO TO 19
C
C     /END
   39 JRANGE=NUMFLG
      GO TO 19
C
C     /OFFSET
   40 JOFFST=NUMFLG
      GO TO 19
C
C     /TERMINAL
   41 JTRMNL=NUMFLG
      GO TO 19
   42 CONTINUE
C
C     **************************************************
C     *                                                *
C     *  OPEN OUTPUT FILE NOW THAT KNOW DEVICE TO USE  *
C     *                                                *
C     **************************************************
C
   43 IF(ITRMNL.EQ.0)OPEN(UNIT=JDISK,DEVICE=3HDSK,
     1FILE=NAMOUT,ACCESS=6HSEQOUT,ERR=44)
      IF(ITRMNL.NE.0)OPEN(UNIT=JDISK,DEVICE=3HTTY,
     1ACCESS=6HSEQOUT,ERR=44)
      MASTER=-MASTER
      GO TO 58
   44 WRITE(ITTY,45)NAMOUT
   45 FORMAT(26H CANNOT WRITE OUTPUT FILE ,1A10)
      GO TO 11
   46 TYPE 47
   47 FORMAT(41H OUTPUT FILE CANNOT SUPERSEDE SOURCE FILE)
      GO TO 11
C
C     ***************************************************
C     *                                                 *
C     *  ASK FOR NAME OF CONTINUATION FILE AND OPEN IT  *
C     *                                                 *
C     ***************************************************
C
   48 IF(ITRMNL.NE.0)GO TO 58
      IF(KRANGE.LT.0)GO TO 58
      WRITE(ITTY,49)
   49 FORMAT(27H SOURCE CONTINUES IN FILE: ,$)
      READ(JTTY,5)NAMSRC
      IF(NAMSRC.EQ.NAMNUL)GO TO 58
      OPEN(UNIT=IDISK,FILE=NAMSRC,ACCESS=5HSEQIN,ERR=50)
      MASTER=-MASTER
      GO TO 58
   50 WRITE(JTTY,51)NAMSRC
   51 FORMAT(31H CANNOT READ CONTINUATION FILE ,1A10)
      GO TO 48
C
C     *********************************************
C     *                                           *
C     *  ASK FOR NAME OF SPLICE FILE AND OPEN IT  *
C     *                                           *
C     *********************************************
C
   52 WRITE(ITTY,53)
   53 FORMAT(14H SPLICE FILE: ,$)
      READ(JTTY,5)NAMSPL
      IF(NAMSPL.EQ.NAMNUL)GO TO 56
      OPEN(UNIT=NDISK,FILE=NAMSPL,ACCESS=5HSEQIN,ERR=54)
      GO TO 58
   54 WRITE(JTTY,55)NAMSPL
   55 FORMAT(25H CANNOT READ SPLICE FILE ,1A10)
      GO TO 52
   56 WRITE(JTTY,57)
   57 FORMAT(30H SPLICE FILE MUST BE SPECIFIED)
      GO TO 52
C
C     *******************************
C     *                             *
C     *  RETURN TO CALLING PROGRAM  *
C     *                             *
C     *******************************
C
   58 RETURN
      END
      SUBROUTINE RNOCMN
C     RENBR(/ITEMS KEPT FOR PDP10 USER COMMAND PARSER)
C
C     FOR A FANCER PARSER, THIS WOULD DECLARE THE COMMON
C     BLOCKS TO BE KEPT FROM ONE RNOASK CALL TO THE NEXT
C
      RETURN
      END
      SUBROUTINE RNOHLP(ITTY)
      WRITE(ITTY,1)
    1 FORMAT(/41H To select options, type any of the follo,
     120Hwing together  on  a/13H single line.//8H /B:numb,
     22Her/6X,41Hcauses all pages to be  suppressed  which,
     314H  precede  the/6X,28Hindicated page.  The page co,
     427Hunt which is used in making/6X,15Hthe  comparison,
     540H  is  1  for  the  first  page  and   is/6X,3Hinc,
     649Hremented  by 1 for each following page regardless,
     73H of/6X,39Hthe page numbers marked on these pages.//
     810H /E:number/6X,32Hcauses all pages to  be  suppres,
     923Hsed  which  follow  the)
      WRITE(ITTY,2)
    2 FORMAT(6X,39Hindicated page.  The page count which i,
     116Hs used in making/6X,26Hthe  comparison  is  1  fo,
     229Hr  the  first  page  and   is/6X,13Hincremented  ,
     342Hby 1 for each following page regardless of/6X,1Ht,
     438Hhe page numbers marked on these pages.//7H /O:num,
     53Hber/6X,40Hcauses the output to be shifted to  the ,
     615H right  by  the/6X,27Hindicated number of columns,
     71H.//3H /P/6X,35Hcauses the output to  be  written  ,
     820Hto  the  controlling/6X,22Hterminal.   The  progr,
     933Ham  will pause at the top of each)
      WRITE(ITTY,3)
    3 FORMAT(6X,39Hnew page and wait for you to hit  the  ,
     116Hcarriage  return/6X,26Hkey  before  continuing.  ,
     229H This  allows  you  to insert/6X,13Hindividual sh,
     332Heets of paper into the terminal.//10H /T:number/
     46X,46Hselects  the  manner  in  which   the   output,
     53X,6Hdevice/6X,34Hrepresents superscript and subscri,
     614Hpt characters./6X,28H/T:0 if output device cannot,
     720H do half-line feeds./6X,22H/T:1 if  current  outp,
     833Hut  device  cannot  do  half-line/6X,9Hfeeds,  b,
     946Hut  document  will  ultimately  be  printed on)
      WRITE(ITTY,4)
    4 FORMAT(6X,39Hdevice which can do  half-line  feeds. ,
     116H  Document  will/6X,26Hhave  to  be  processed  a,
     229Hgain  to  produce  the  final/6X,8Hversion./6X,
     349H/T:2 if output device is  Diablo  or  Xerox  dais,
     46Hywheel/6X,37Hterminal with uni-directional form tr,
     56Hactor./6X,37H/T:3 if output device is  Diablo  or ,
     618H Xerox  daisywheel/6X,24Hterminal with bi-directi,
     718Honal form tractor.//3H /V/6X,17Hcauses the output,
     838H to  be  written  to  the  controlling)
      WRITE(ITTY,5)
    5 FORMAT(6X,39Hterminal.   The  program  will  not pau,
     116Hse at the top of/6X,26Heach new page unless /P is,
     216H issued instead.//12H The command/6X,9H/P/O:12/B,
     37H:6/E:10/39H would write  the  sixth  through  the ,
     422H tenth  pages  to  the/23H terminal, pausing at t,
     538Hhe top of each page, and shifting each/8H line 12,
     622H columns to the right./)
      RETURN
      END
