home *** CD-ROM | disk | FTP | other *** search
/ ftp.update.uu.se / ftp.update.uu.se.2014.03.zip / ftp.update.uu.se / pub / rainbow / msdos / decus / RB101 / day.for < prev    next >
Text File  |  1995-05-19  |  9KB  |  401 lines

  1. $STORAGE: 2
  2. $NOFLOATCALLS
  3. c-----------------------------------------------------------------------
  4. c
  5. c    Daily Appointment subroutine
  6. c
  7. c    part of Mitch Wyle's DTC program
  8. c
  9. c    Input: 
  10. c       line - 72 characters;  Format: D [mmddyy [hh:mm>HH:MM [appointment]]]
  11. c
  12. c    Output:
  13. c        display screen (see below)
  14. c
  15. c-----------------------------------------------------------------------
  16. c
  17.  
  18.     SUBROUTINE day(line2)
  19.  
  20. c
  21. c    Declarations:
  22. c
  23.     CHARACTER LINE2(80)
  24.     character line(80)        
  25.     CHARACTER*18 LINE16
  26.     EQUIVALENCE(LINE(1),LINE16)
  27. c     input line
  28.     CHARACTER*2 TEMP2
  29.     character temp(2)        
  30.     EQUIVALENCE(TEMP(1),TEMP2)
  31. c     temporary string converting array
  32.     character appoin(60)        
  33. c     appointment string
  34.     character work(60)           
  35. c   scratch array for handling scheduling
  36.     character esc        
  37. c     escape character
  38.     integer    id        
  39. c     Julian Day
  40.     integer im        
  41. c     Julian Month
  42.     integer iye        
  43. c     Julian Year
  44.     integer rdspfg          
  45. c   flag to reverse sense of display of time
  46.     character junk(130)
  47.     integer ctlfg           
  48. c   misc control flags here
  49.     INTEGER IDYR,IDMO,IDDY
  50.     COMMON/DEFDAT/IDYR,IDMO,IDDY
  51.     common/ctls/rdspfg,ctlfg
  52.     character fname(60)
  53.     CHARACTER*18 FNAM60
  54.     EQUIVALENCE(FNAME(1),FNAM60)
  55.     integer fnsz
  56.     common/fn/fnsz,fname
  57.  
  58. c
  59. c    Initialize:
  60. c
  61.     DO 933 IV=1,80
  62. 933    LINE(IV)=LINE2(IV)
  63.     iterm = 0        
  64. c     Output terminal unit number
  65.     esc = 27        
  66. c     Escape character
  67. C    call idate(im,id,iye)    
  68. c     initialize to today's date
  69.     IM=IDMO
  70.     ID=IDDY
  71.     IYE=IDYR
  72.  
  73. c
  74. c        Parse that line
  75. c
  76. c        Was there a D on the front?  If so, trim it off:
  77. c
  78.  
  79.     IDMX=0
  80.     If ( line(1) .eq. 'D' .or.line(1).eq.'d') then
  81.         Do 1 i=1,70
  82.         line(i) = line(i+2)
  83. 1        Continue
  84.  
  85.     End If
  86.  
  87.  
  88. c
  89. c        If the date was specified in command line then
  90. c        set id, im and iye to the right values:
  91. c
  92.  
  93.     CALL DATMUN(LINE)
  94.     Do 22 i=1,6
  95.         IDL=I
  96.         If ( ( line(i) .gt. '9' ) .or. ( line(i) .lt. '0' ) ) goto 33
  97. 22    Continue
  98.  
  99. c    Six numbers in a row, so decode into numeric date:
  100.  
  101.         temp(1) = line(1)
  102.         temp(2) = line(2)
  103.     read(temp2,2)im
  104. c        decode ( 2 , 2 , temp ) im
  105.         temp(1) = line(3)
  106.         temp(2) = line(4)
  107. c        decode ( 2 , 2 , temp ) id
  108.     read(temp2,2)id
  109.         temp(1) = line(5)
  110.         temp(2) = line(6)
  111. c        decode ( 2 , 2 , temp ) iye
  112.     read(temp2,2)iye
  113.     IDDY=ID
  114.     IDYR=IYE
  115.     IDMO=IM
  116. 2    Format(i2)
  117.  
  118. c
  119. c        Now discard the date part from line string:
  120. c
  121.  
  122.         Do 3 i=1,63
  123.         line(i) = line(i+7)
  124. 3        continue
  125.     GOTO 3307
  126. 33    continue
  127. C GOT A DELIMITER NOT A NUMERIC IN 1ST 6 COLS SO MAKE THAT THE START OF LINE
  128. C BY CHOPPING OFF ALL THAT'S EARLIER
  129.     IF(IDL.LE.0.OR.IDL.GT.6)GOTO 3307
  130.     DO 3308 I=1,63
  131.         LINE(I)=LINE(I+IDL)
  132. 3308    CONTINUE
  133. 3307    CONTINUE
  134. c
  135. c        Clear the screen, move the cursor to the top part,
  136. c        set up appointments screen:
  137. c
  138.  
  139.     write(iterm,4) esc,'[','2','J',esc,'[','0','1',';','0',
  140.      1  '1','H'
  141. 4    format(1X,79a1)
  142.  
  143.     write(iterm,5) im,id,iye
  144. 5    format(1X,10X,'Appointments For ',i2,'/',i2,'/',i2,/)
  145.  
  146.     Do 8 i=8,16
  147.         If ( i .gt. 12 ) then
  148.         j = i - 12
  149.         Else
  150.         j = i
  151.         End If
  152.         write(iterm,6) j
  153. 6        format(1x,i2,':00   -')
  154.         write(iterm,7) j
  155. 7        format(1x,i2,':30   -')
  156. 8    Continue
  157.  
  158.     write(iterm,9)
  159. 9    format(1x,'Evening:',/,79('='))
  160.  
  161. c
  162. c    Was a time input?  Did it accompany an appointment string?
  163. c    Why do fools fall in love?
  164. c
  165.     IDMX=0
  166.     if(line(1).eq.'e')LINE(1)='E'
  167.     If (((line(1).le.'9').and.(line(1).ge.'0')).OR.LINE(1)
  168.      1   .EQ.'E') then
  169.  
  170. c
  171. c        Parse the time string
  172. c
  173.       IF(LINE(1).NE.'E') THEN
  174.  
  175.         If ( line(2) .eq. ':' ) then
  176.         temp(1) = '0'
  177.         temp(2) = line(1)
  178.     READ(TEMP2,2)IHT
  179. C        decode ( 2 , 2 , temp2 ) iht
  180.         if ( iht .lt. 5 ) iht = iht + 12
  181.         IHHR=IHT
  182.         iht = iht * 10
  183.         If ( line(3) .eq. '3' ) iht = iht + 3
  184.         Else If ( line(3) .eq. ':' ) then
  185.         temp(1) = line(1)
  186.         temp(2) = line(2)
  187.       READ(TEMP2,2)IHT
  188. C        decode ( 2 , 2 , temp2 ) iht
  189.         If ( iht .lt. 5 ) iht = iht + 12
  190.         IHHR=IHT
  191.         iht = iht * 10
  192.         If ( line(4) .eq. '3' ) iht = iht + 3
  193.         End If
  194.       END IF
  195. C HANDLE "EV" MODIFIER FOR EVENING APPOINTMENTS
  196.     IF(LINE(1).EQ.'E')IHT=170
  197. C 170 IS SPECIAL EVENING CODE..... CORRESPONDS TO 5PM...
  198.     IHMX=1
  199.     IDHR=0
  200.     IOMX=6
  201.     IF (LINE(6).EQ.'>') THEN
  202. C IF 2 RANGES EXIST DUPLICATE MESSAGE AFTER EXTRACTING 2ND RANGE
  203. C OF HH:MM
  204.     temp(1)=line(7)
  205.     temp(2)=line(8)
  206.     READ(temp2,2)ihmx
  207. c        DECODE(2,2,LINE(7))IHMX
  208.         IF(IHMX.LT.5)IHMX=IHMX+12
  209. c        DECODE(2,2,LINE(10))IMMX
  210.     temp(1)=line(10)
  211.     temp(2)=line(11)
  212.     READ(temp2,2)immx
  213.         IF(IMMX.NE.30)IMMX=0
  214. C COUNT HALF HOURS IN GIVEN INTERVAL ...
  215.         IDHR=(IHMX-IHHR)*2
  216. C FIND NUMBER ENTRIES TO SHOVE OUT...
  217.         IF(IMMX.NE.0)IDHR=IDHR+1
  218.         IF(IHT.NE.(10*IHHR))IDHR=IDHR-1
  219.         IDHR=MAX0(1,IDHR)
  220.         IDMX=IDHR
  221. C ABOVE CLAMPS POSITIVE... NO INVALID ENTRIES PLEASE...
  222.         IOMX=12
  223.     END IF
  224. c
  225. c        Now look for space delimiter to trim off the time
  226. c        of day part, and then extract the appointment:
  227. c
  228.  
  229. C USE IOMX SO WE SCAN PAST 2ND RANGE IF ANY...
  230.         Do 11 io=1,IOMX
  231.         If ( line(1) .eq. ' ') goto 12    
  232. c  Found a space; exit loop
  233.         Do 10 i=1,71
  234.             line(i) = line(i+1)
  235. 10        Continue
  236. 11        Continue
  237. 12        Continue                
  238. c  Label to Exit loop
  239.  
  240. c
  241. c        Was there an appointment string input?
  242. c        If so, put it in file, and display it on screen.
  243. c        If not, move cursor to correct time on screen,
  244. c        then input the appointment, put in file and re-display it.
  245. c
  246.         If ( line(1) .lt. ' ' ) then
  247.         itemp = iht / 10
  248.         if ( itemp .gt. 7 ) itemp = itemp - 7
  249.         iy = 2 * itemp + 1
  250.         If ( ( ( iht/10 ) * 10 ) .ne. iht ) iy = iy + 1
  251.         ix = 10
  252.         call dtcat(ix,iy)
  253. c        close(iterm)
  254. C ... SLIGHTLY SCREWY CODE HERE...
  255.     write(0,1955)
  256. 1955    format('+ Enter appt here:')
  257.         read(0,913,END=914) (line(i),i=1,60)
  258. 913        format(1X,60a1)
  259. 13        format('+',60a1)
  260. 914        CONTINUE
  261.         End If
  262. c copy appointment for use later...
  263.     Do 1118 ivx=1,60
  264. 1118    work(ivx)=line(ivx)
  265.     iwy=iye
  266.     iwm=im
  267.     iwd=id
  268.     iwht=iht
  269.         If ( line(1) .ge. ' ' ) then
  270. C ADD CLOSE TO GUARANTEE NO FAILURES...
  271.                 CLOSE(1)
  272. C  If we are using the 'S' command, ONLY add meetings to the indirected
  273. C  files, not to the current (control) file.
  274.     IF(CTLFG.NE.1) THEN
  275.         Open ( 1,file=FNAM60,status='OLD',form='FORMATTED')
  276.     do 8877 iv=1,9999
  277. c simulate append access by reading to eof
  278.     read(1,8879,end=8878,err=8878)junk
  279. 8879    format(130a1)
  280. 8877    continue
  281. 8878    continue
  282.     backspace 1
  283.     BACKSPACE 1
  284.         IHTSV=IHT
  285.         IF(IDMX.LT.1)IDMX=1
  286.         DO 3005 IVX=1,IDMX
  287.         write(1,614) iye,im,id,iht,(line(i),i=1,60)
  288.         IF((IHT/10)*10.EQ.IHT)THEN
  289. 614        format(3i2,i3,60a1)
  290. C THIS IS AN EVEN HOUR ... ADD THE HALF HOUR
  291.             IHT=IHT+3
  292.         ELSE
  293. C IHT IS A HALF HOUR ... MAKE UP TO NEXT HOUR
  294.             IHT=IHT+7
  295.         END IF
  296. 3005        CONTINUE
  297.         IHT=IHTSV
  298. 14        format(3i2,i3,60a1,\)
  299.     write(1,1600)
  300. 1600    format(/)
  301.         close(1)
  302.     END IF
  303.         End If
  304.     End If
  305.  
  306.     nunit=1
  307.     Open (nunit,file=FNAM60,status='OLD' ,form='FORMATTED')
  308.  
  309. 100    continue    
  310. c     loop back up here to continue reading and
  311.             
  312. c     processing input file:
  313.  
  314.  
  315.     read(nunit,200,end=400) ihy,ihm,ihd,iht,(line(k),k=1,60)
  316. 200    format(3i2,i3,60a1)
  317.     if(ihy.eq.99.and.nunit.eq.1)then
  318.     nunit=2
  319. c null terminate the filename somewhere
  320. c lines with 99 in 1st 2 cols are filenames only...
  321. c use = as delimiter of filename
  322.     line(60)=32
  323.     kkk=0
  324.     do 1068 ii=1,59
  325.     if(line(ii).le.31.or.line(ii).eq.'=')kkk=1
  326.     if(kkk.gt.0)line(ii)=32
  327. c    if(line(ii).eq.'=')line(ii)=32
  328. 1068    continue
  329. C SKIP WRITING IN SUBSIDIARY FILES IF NOT APPORPRIATE FOR COMMAND...
  330.     if(CTLFG.eq.0) goto 1119
  331. c ****
  332. c on scheduling multiple dates via the S function, use this occasion to
  333. c add the record to everyone's calendar file.
  334.                 CLOSE(2)
  335.         Open ( 2,file=line16,status='OLD',form='FORMATTED')
  336.     do 8977 iv=1,9999
  337. c simulate append access by reading to eof
  338.     read(2,8979,end=8978,err=8978)junk
  339. 8979    format(130a1)
  340. 8977    continue
  341. 8978    continue
  342.     backspace 2
  343.     backspace 2
  344.         IHTSV=IHT
  345.         iht=iwht
  346.         IF(IDMX.LT.1)IDMX=1
  347.         DO 3007 IVX=1,IDMX
  348.         write(2,614) iwy,iwm,iwd,iht,(work(i),i=1,60)
  349.         IF((IHT/10)*10.EQ.IHT)THEN
  350. C IF THIS IS AN EVEN HOUR ... ADD THE HALF HOUR
  351.             IHT=IHT+3
  352.         ELSE
  353. C IF THIS IS A HALF HOUR ... MAKE UP TO NEXT HOUR
  354.             IHT=IHT+7
  355.         END IF
  356. 3007        CONTINUE
  357.         IHT=IHTSV
  358.     write(2,1600)
  359.        close(2)
  360. c ****
  361. 1119    continue
  362.     CLOSE(NUNIT)
  363. c7663    continue
  364.     DO 7660 II=1,40
  365. 7660    IF(LINE(II).LE.' ')LINE(II)=' '
  366.     IF(LINE(1).EQ.' ')THEN
  367.      DO 7661 II=1,40
  368. 7661     LINE(II)=LINE(II+1)
  369. c    goto 7663
  370.     END IF
  371.     Open(nunit,file=line16,status='old',form='formatted')
  372.     goto 100
  373.     end if
  374.     If ((iye .eq. ihy) .and. (im .eq. ihm) .and. (id .eq. ihd)) then
  375.         itemp = iht / 10
  376.         if ( itemp .gt. 7 ) itemp = itemp - 7
  377.         iy = 2 * itemp + 1
  378.         If (((iht/10)*10) .ne. iht)    iy = iy + 1
  379.         ix = 10
  380.         call dtcat(ix,iy)
  381.         write(iterm,300) (line(k),k=1,60)
  382. 300        format(1X,60a1,\)
  383.         call dtcat(1,22)
  384.     End If
  385.     goto 100
  386.  
  387. 400    continue    
  388. c  no more appointments left in file.
  389.     if(nunit.ne.1)then
  390. 1067    continue
  391.     close(2)
  392.     nunit=1
  393.     goto 100
  394.     end if
  395.     close(1)
  396.     return
  397.     end
  398.  
  399.  
  400.