home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 3 / PDCD_3.iso / pocketbk / developmen / agenda / READAGN.OPL < prev   
Text File  |  1992-03-19  |  2KB  |  133 lines

  1. PROC readAgn:
  2.     global secs&,s,yr%,mo%,dy%,hh%,mm%,ss%,yrday%
  3.     global f$(128),rtype$(6,15)
  4.     f$="\agn\*.agn"
  5.     rtype$(1)="yearly"
  6.     rtype$(2)="monthly by date"
  7.     rtype$(3)="monthly by day"
  8.     rtype$(4)="weekly"
  9.     rtype$(5)="daily"
  10.     rtype$(6)="workdays"
  11.     while 1
  12.         dInit "Select Agenda file to display"
  13.         dFile f$,"Agenda file",0
  14.         if dialog = 0
  15.             stop
  16.         endif
  17.         trap open f$,a,day%,dur%,tim%,alm%,t$
  18.         if err
  19.             cls
  20.             print err$(err)
  21.         else
  22.             first
  23.             ScanRecs:
  24.             close
  25.         endif
  26.     endwh
  27. ENDP
  28.  
  29. PROC ScanRecs:
  30.     local b%
  31.     while 1
  32.         Output:
  33.         while 1
  34.             dInit
  35.             dPosition 1,1
  36.             dButtons "Back",8,"Next",13
  37.             b%=dialog
  38.             if b%=13
  39.                 if pos>=count
  40.                     giprint "At end of file",2
  41.                     continue
  42.                 endif
  43.                 next
  44.                 break
  45.             elseif b%=8
  46.                 if pos<=1
  47.                     giprint "At start of file",2
  48.                     continue
  49.                 endif
  50.                 back
  51.                 break
  52.             else
  53.                 return
  54.             endif
  55.         endwh
  56.     endwh
  57. ENDP
  58.  
  59. PROC Output:
  60.     local t$(70),ty%,in%,st%,en%
  61.     local ad%,l%
  62.     cls
  63.     t$=a.t$
  64.     if a.day% = -1
  65.         print t$
  66.         print "To-do item"
  67.         print "Priority:",a.tim%
  68.         print "2nd key:",a.dur%/2
  69.         return
  70.     elseif a.day% = -2
  71.         l%=len(t$)-6
  72.         ad%=addr(t$)
  73.         pokeb ad%,l%
  74.         ty%=peekb(ad%+l%+1)
  75.         in%=peekb(ad%+l%+2)
  76.         st%=peekw(ad%+l%+3)
  77.         en%=peekw(ad%+l%+5)
  78.         print t$
  79.         if ty%<0 or ty%>5
  80.             print "*** Unknown repeat type ***"
  81.         else
  82.             print "Repeat",rtype$(ty%+1)
  83.         endif
  84.         print "Interval",in%
  85.         prntDay:("Start day:",st%)
  86.         if en%
  87.             prntDay:("End day:",en%)
  88.         else
  89.             print "Repeating forever"
  90.         endif
  91.     else
  92.         print t$
  93.         prntDay:("Day:",a.day%)
  94.     endif
  95.     if a.tim% and $8000
  96.         print "Untimed"
  97.     else
  98.         print "Timed"
  99.     endif
  100.     if (a.tim% and $8000) <> $8000
  101.         prntTime:("Time:",a.tim% and $7fff)
  102.         prntTime:("Duration:",a.dur%/2)
  103.     endif
  104.     if (a.dur% and $1) <> $1
  105.         if a.tim% and $8000
  106.             print "Alarm days previous: ";a.alm%/(24*60)
  107.             prntTime:("Alarm: ",(23*60+59)-(a.alm%-((a.alm%/(24*60))*(24*60))))
  108.         else
  109.             prntTime:("Alarm: ",(a.tim% and $7fff)-(23*60+59)+a.alm%)
  110.         endif
  111.     else
  112.         print "No alarm set"
  113.     endif
  114. ENDP
  115.  
  116. PROC prntTime:(s$,t%)
  117.     print s$,t%/60;":";t%-((t%/60)*60)
  118. ENDP
  119.  
  120. PROC prntDay:(p$,d%)
  121.     secs&=d%
  122.     secs&=secs&-days(1,1,1970)
  123.     secs&=secs& and &ffff 
  124.     s=secs&
  125.     s=s*86400
  126.     if s>2147483647
  127.         s=s-4294967296
  128.     endif
  129.     secs&=s
  130.     secstodate secs&,yr%,mo%,dy%,hh%,mm%,ss%,yrday%
  131.     print p$,dy%;"/";mo%;"/";yr%
  132. ENDP
  133.