OPTIONS X
C  C:\AUTOSIG\MAKE_SCR.FOR
C
C  This UTAH FORTRAN program creates an .SCR file for AUTOSIG to
C  access BASICQUOTES.  It assumes the default directory is C:\AUTOSIG
C  and all files are located there unless a configuration control file
C  exists.
C
C  Inputs:
C     TICKER.LST   - List of stock symbols in Fortran A6 format.
C     PROGRAM.CTL  - Configuration control file containing drives, paths,
C                    and PROGRAM file name if not C:\AUTOSIG\AUTOSIG.EXE
C
C  Outputs:
C     ATOSTART.BAT - Batch file for automatic operation.
C     DYyymmdd.LOG - Session log of the quotes recieved.
C     DYyymmdd.SCR - SCR file envoked by ATOSTART when AUTOSIG is started.
C       where   yy - Year
C               mm - Month
C               dd - Day
C
C  Rev. 0    Clinton D. Huntemann    -   April 27, 1992
C            (71247,2065)
C            5 Longwood Avenue
C            Londonderry, New Hampshire 03053
C            phone (603) 432-7554
C
C  Rev. 1    Clinton D. Huntemann    -   May 6, 1992
C            Added '/Z' to the script file to automatically logout
C            from AUTOSIG (allows unattended operation).  Also, added 
C            PROGRAM.CTL for variable configuration control.  STRIPPER
C            was added to the processing stream in ATOSTART.BAT.
C
C  Rev. 1A   Clinton D. Huntemann    -   May 13, 1992
C            Fixed embarassing errors.
C
C  Rev. 1B   Clinton D. Huntemann    -   May 23, 1992
C            Adjusted script file to compensate for missing or not
C            found symbols.  (Part of overall GETQUOTE fix.)
C
C  Rev. 2    Clinton D. Huntemann    -   Oct. 25, 1992
C            Added code to skip weekends.
C
C  Rev. 2A   Clinton D. Huntemann    -   Nov. 27, 1992
C            Incorporated weekend skip code into subroutine to search a
C            file NODAYS.DAT for a list of holidays and other days the
C            market may be closed.
C
C  Rev. 2B   Clinton D. Huntemann    -   Jan. 9, 1993
C            Fixed some poor control commands in ATOSTART.BAT when run
C            without a PROGRAM.CTL file.
C
      DIMENSION FNAME1(2),FNAME2(2),MPATH(10),PATH1(10),PATH2(10),
     1PATH3(10),ATO(2),DRV(10)
      REAL RYR,RMO,RDY
      INTEGER MONTH,DAY,YEAR,WEEK,SKIP
C
C Update data file name based on system date
C
      CALL DATE(MONTH,DAY,YEAR,WEEK)
      YEAR = YEAR-100*INT(YEAR/100)
      ENCODE (RMO,2,4001) MONTH
 4001 FORMAT (I2)
      IF (MONTH .LT. 10) ENCODE (RMO,2,4002) MONTH
 4002 FORMAT ('0',I1)
      ENCODE (RDY,2,4001) DAY
      IF (DAY .LT. 10) ENCODE (RDY,2,4002) DAY
      ENCODE (RYR,2,4001) YEAR
      IF (YEAR .LT. 10) ENCODE (RYR,2,4002) YEAR
      ENCODE (FNAME1,14,4003) RYR,RMO,RDY
 4003 FORMAT ('DY',3A2,'.LOG')
      ENCODE (FNAME2,14,4004) RYR,RMO,RDY
 4004 FORMAT ('DY',3A2,'.SCR')
C
C Retrieve the configuration file
C
      DO 51 I=1,10
      DRV(I) = 'C:    '
      MPATH(I)='      '
      PATH1(I)='      '
      PATH2(I)='      '
   51 PATH3(I)='      '
      ENCODE (MPATH,8,5003) '\5C\AUTOSIG'
 5003 FORMAT (10A6)
      ENCODE (PATH1,8,5003) '\5C\AUTOSIG'
      ENCODE (PATH2,8,5003) '\5C\AUTOSIG'
      ENCODE (PATH3,8,5003) '\5C\AUTOSIG'
      ENCODE (ATO,8,5003) 'AUTOSIG '
      IERR=0
      CALL OPEN (4,'PROGRAM.CTL',IERR)
      IF (IERR .NE. 0) GOTO 59
      READ (4,5005) DRV
 5005 FORMAT (12X,10(A2,1X))
      READ (4,5004) ATO
 5004 FORMAT (12X,A6,A2)
      READ (4,5006) MPATH
 5006 FORMAT (12X,10A6)
      READ (4,5006) PATH1
      READ (4,5006) PATH2
      READ (4,5006) PATH3
      CALL CLOSE (4)
C
C Update the AUTOSIG Batch File
C
   59 CALL OPEN (5,'ATOSTART.BAT')
      WRITE (5,4999) FNAME2
 4999 FORMAT ('echo Starting ATOSTART for ',2A6)
      IF ((DRV(1).NE.'C:    ').AND.(DRV(1).NE.'      '))
     1WRITE (5,5000) DRV(1),MPATH
 5000 FORMAT ('SUBST ',A2,' ',10A6)
      IF ((DRV(2).NE.'C:    ').AND.(DRV(2).NE.'      '))
     1WRITE (5,5000) DRV(2),PATH1
      IF ((DRV(3).NE.'C:    ').AND.(DRV(3).NE.'      '))
     1WRITE (5,5000) DRV(3),PATH2
      IF ((DRV(4).NE.'C:    ').AND.(DRV(4).NE.'      '))
     1WRITE (5,5000) DRV(4),PATH3
      CALL NODAY(SKIP)
      IF (SKIP .NE. 0) GOTO 60
      WRITE (5,5002) DRV(1),ATO,FNAME2
 5002 FORMAT ('call ',A2,A6,A2,' /Z/X',2A6)
      WRITE (5,5001)
 5001 FORMAT ('call STRIPPER')
   60 DO 61 M=1,10
   61 IF ((DRV(M).NE.'C:    ').AND.(DRV(M).NE.'      '))
     1WRITE (5,5007) DRV(M)
 5007 FORMAT ('SUBST ',A2,' /d')
      CALL CLOSE (5)
C
C Create the .SCR file
C
      CALL OPEN (5,FNAME2)
      WRITE (5,6000)
 6000 FORMAT (' sendline ATDT %HOSTPHONE'/' match CONNECT')
      WRITE (5,6001)
 6001 FORMAT (' pause 1'/' send ''^C'''/' match ''User ID:''')
      WRITE (5,6002)
 6002 FORMAT (' display ''{'' %COM ''}'''/' sendline %HOSTUSERID')
      WRITE (5,6003)
 6003 FORMAT (' if %hostuserid ''\5C\'' then goto have.pswd')
      WRITE (5,6004)
 6004 FORMAT ('  match ''Password:'''/' sendline %HOSTPASSWORD')
      WRITE (5,6005)
 6005 FORMAT ('label have.pswd'/' sendline SET BRIEF NO'
     1/' match ''choice''')
      WRITE (5,6006) DRV(2),FNAME1
 6006 FORMAT (' capture ',A2,2A6)
C
C Open the Ticker List file
C
      CALL OPEN (4,'TICKER.LST')
   99 WRITE (5,6007)
 6007 FORMAT (' sendline ''GO BASICQUOTE''')
      IF ((WEEK .EQ. 0).OR.(WEEK .EQ. 6)) GOTO 200
C
C Cycle through the ticker symbols on file (if not a weekend)
C
      DO 101 K=1,3
      READ (4,6009,ERR=199,END=200) TICKER
 6009 FORMAT (1A6)
      WRITE (5,6008) TICKER
 6008 FORMAT (' match ''Issue:'''/' sendline ''',A6,Z)
      DO 100 I=2,6
      READ (4,6009,ERR=199,END=101) TICKER
  100 WRITE (5,6010) TICKER
 6010 FORMAT (',',A6,Z)
  101 WRITE (5,6011)
 6011 FORMAT ('''')
      WRITE (5,6012)
 6012 FORMAT (' match ''Issue:'''/' send ''^M''')
      GO TO 99
C
C Close the Script file
C
  200 CALL CLOSE (4)
      WRITE (5,6013)
 6013 FORMAT (' match ''Issue:'''/' capture OFF'/' send ''^M'''/
     1' exit Z')
C
C Cleanup and exit
C
      CALL CLOSE (5)
      WRITE (0,7000) FNAME2,FNAME1
 7000 FORMAT (//'Files ATOSTART.BAT and ',2A6,' created.'/
     1'To start, type ATOSTART'/
     2'File ',2A6,' will be created when ATOSTART is run.'//)
      STOP 'Normal stop'
C
  199 CALL CLOSE (4)
      CALL CLOSE (5)
      WRITE (0,7099) FNAME2,FNAME2
 7099 FORMAT ('Error creating files ATOSTART.BAT or ',2A6,'.'/
     1'DO NOT USE ',2A6,'.'//)
      STOP 'Abnormal stop'
      END
      SUBROUTINE NODAY(SKIP)
C
C   This Subroutine looks up a list of dates to skip processing
C   (i.e. days the market is closed).  It returns SKIP > 0 if current
C   date is a weekend or matches a date in the list.
C
C
C   Programm Originator:
C        Clinton D. Huntemann  (71247,2065)
C        5 Longwood Avenue
C        Londonderry, New Hampshire 03053
C        phone (603) 432-7554
C
C   Revision History:
C        Rev. 0 - November 28, 1992       CDH
C                 Original
C
C
      DIMENSION LINE(7)
      INTEGER MONTH,DAY,YEAR,WEEK,SKIP
C
C   Get current date
C
      CALL DATE(MONTH,DAY,YEAR,WEEK)
      IF ((WEEK.EQ.0).OR.(WEEK.EQ.6)) THEN
          SKIP = 6
          TYPE 'Processing skipped for weekends'
          RETURN
          ENDIF
C
C   Open list of skipped days
C
      CALL OPEN (4,'NODAYS.DAT',SKIP)
      IF (SKIP.NE.0) THEN
          TYPE 'NODAYS.DAT file not found'
          SKIP = 0
          RETURN
          ENDIF
      READ (4,1000,END=199) LINE
 1000 FORMAT (7A6)
      READ (4,1000,END=199) LINE
C
C   Look for dates match
C
  100 READ (4,1000,END=199) LINE
      DECODE (LINE,10,1001) IMO,IDY,IYR
 1001 FORMAT (2(I2,1X),I4)
      IF ((IMO.EQ.MONTH).AND.(IDY.EQ.DAY).AND.(IYR.EQ.YEAR)) THEN
          SKIP = 1
          CALL CLOSE (4)
          TYPE 'Processing skipped via NODAYS.DAT entry'
          WRITE (1,1000) LINE
          RETURN
          ENDIF
      GOTO 100
  199 SKIP = 0
      CALL CLOSE (4)
      RETURN
      END
