home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 3 / PDCD_3.iso / pocketbk / developmen / oplexamp / CLOCKCRD.OPL < prev    next >
Text File  |  1993-08-23  |  4KB  |  169 lines

  1. PROC clockcrd:
  2.     REM Written by Doug Sargeant 23/8/93.
  3.     REM Castle Computer Services. 0268 776158.
  4.     global in1&(5),out1&(5),in2&(5),out2&(5),cred&(5),deb&(5)
  5.     GLOBAL ANSWER%
  6.     global dayno%
  7.     global bftot&,cftot&
  8.     readbal:
  9.     hdprint:
  10.     dayno% =1
  11.     do
  12.     dinit "Select Day"
  13.     dchoice dayno%,"Day","Monday,Tuesday,Wednesday,Thursday,Friday,End"
  14.     dialog
  15.     if dayno%=6
  16.         break
  17.     endif
  18.     do
  19.         dayedit:
  20.         daycalc:
  21.         ANSWER%=OKDIAL%:
  22.     UNTIL ANSWER%
  23.     wkcalc:
  24.     until 0
  25.     get
  26.     writebal:
  27. ENDP
  28.  
  29. proc dayedit:
  30.     dinit
  31.     dtime in1&(dayno%),"IN1:",0,0,99999999
  32.     dtime out1&(dayno%),"OUT1:",0,0,9999999
  33.     dtime in2&(dayno%),"IN2:",0,0,99999999
  34.     dtime out2&(dayno%),"OUT2:",0,0,99999999
  35.     dtime deb&(dayno%),"DEBIT:",2,0,43200
  36.     dtime cred&(dayno%),"CREDIT:",2,0,43200
  37.     if dayno%=1
  38.         dposition 0,-1
  39.     elseif dayno%<=4
  40.         dposition 1,-1
  41.     else
  42.         dposition -1,-1
  43.     endif
  44.     dialog
  45. endp
  46.  
  47. proc hdprint:
  48. local bfdeb&,bfcred&
  49. cls
  50. print "    Mon  Tue  Wed  Thur Fri ";
  51. print "  B/F ";hhhmm$:(bftot&);
  52. print "In"
  53. print "Out"
  54. print "In"
  55. print "Out"
  56. print "Db"
  57. print "Cr"
  58. endp
  59.  
  60. proc daycalc:
  61.     local daytot&,diff&
  62.     daytot&=out1&(dayno%)-in1&(dayno%)+out2&(dayno%)-in2&(dayno%)+cred&(dayno%)-deb&(dayno%)
  63.     DIFF&=DAYTOT&-(60*7+12)*60
  64.     at dayno%*5-1,2
  65.     print hhmm$:(in1&(dayno%));
  66.     at dayno%*5-1,3
  67.     print hhmm$:(out1&(dayno%));
  68.     at dayno%*5-1,4
  69.     print hhmm$:(in2&(dayno%));
  70.     at dayno%*5-1,5
  71.     print hhmm$:(out2&(dayno%));
  72.     at dayno%*5-1,6
  73.     print hhmm$:(deb&(dayno%));
  74.     at dayno%*5-1,7
  75.     print hhmm$:(cred&(dayno%));
  76.     at dayno%*5-1,8
  77.     print hhmm$:(daytot&);
  78.     at dayno%*5-1,9
  79.     PRINT HHMM$:(DIFF&);
  80. endp
  81.  
  82. proc hhmm$:(secs&)
  83.     local Y%,Mo%,d%,H%,Mn%,sc%,yrday%
  84.     local h$(2),Mn$(2)
  85.     local sign$(1),secspos&
  86.     if secs& >= 0
  87.         secspos&=secs&
  88.         sign$=":"
  89.     else
  90.         secspos&=-secs&
  91.         sign$="-"
  92.     endif
  93.     secstodate secspos&,Y%,Mo%,d%,H%,Mn%,sc%,yrday%
  94.     h$=num$(h%,-2)
  95.     mn$=num$(mn%,-2)
  96.     if left$(mn$,1)=" "
  97.         mn$="0" + right$(mn$,1)
  98.     endif
  99.     return h$ + sign$ + mn$
  100. endp
  101.  
  102. proc hhhmm$:(secs&)
  103.     local Y%,Mo%,d%,H%,Mn%,sc%,yrday%
  104.     local h$(3),Mn$(3)
  105.     local sign$(1),secspos&
  106.     if secs& >= 0
  107.         secspos&=secs&
  108.         sign$=":"
  109.     else
  110.         secspos&=-secs&
  111.         sign$="-"
  112.     endif
  113.     secstodate secspos&,Y%,Mo%,d%,H%,Mn%,sc%,yrday%
  114.     h$=num$((d%-1)*24 + h%,-3)
  115.     mn$=num$(mn%,-2)
  116.     if left$(mn$,1)=" "
  117.         mn$="0" + right$(mn$,1)
  118.     endif
  119.     return h$ + sign$ + mn$
  120. endp
  121.  
  122. PROC OKDIAL%:
  123.     DINIT "CORRECT?"
  124.     DBUTTONS "Yes",%Y,"No",%N
  125.     if dayno%=5
  126.         dposition -1,0
  127.     elseif dayno%>=2
  128.         dposition 1,0
  129.     endif
  130.     return dialog=%y
  131. ENDP
  132.  
  133. proc wkcalc:
  134.     local in1tot&,in2tot&
  135.     local out1tot&,out2tot&
  136.     local debtot&,credtot&
  137.     local dbtot&,crtot&
  138.     local stdhr&
  139.     local totcr&,totdb&
  140.     stdhr&=int(36)*60*60:rem int to force prevent o/flow
  141.     in1tot&=in1&(1)+in1&(2)+in1&(3)+in1&(4)+in1&(5)
  142.     out1tot&=out1&(1)+out1&(2)+out1&(3)+out1&(4)+out1&(5)
  143.     in2tot&=in2&(1)+in2&(2)+in2&(3)+in2&(4)+in2&(5)
  144.     out2tot&=out2&(1)+out2&(2)+out2&(3)+out2&(4)+out2&(5)
  145.     debtot&=deb&(1)+deb&(2)+deb&(3)+deb&(4)+deb&(5)
  146.     credtot&=cred&(1)+cred&(2)+cred&(3)+cred&(4)+cred&(5)
  147.     dbtot&=in1tot&+in2tot&+debtot&+stdhr&
  148.     crtot&=bftot&+out1tot&+out2tot&+credtot&
  149.     cftot&=crtot&-dbtot&
  150.     at 29,2:print hhhmm$:(in1tot&);" ====="
  151.     at 30,3:print "=====";hhhmm$:(out1tot&);
  152.     at 29,4:print hhhmm$:(in2tot&);" ====="
  153.     at 30,5:print "=====";hhhmm$:(out2tot&);
  154.     at 29,6:print hhhmm$:(debtot&);" =====";
  155.     at 29,7:print hhhmm$:(stdhr&);" ";hhhmm$:(credtot&);
  156.     at 29,8:print hhhmm$:(dbtot&);hhhmm$:(crtot&)
  157.     at 30,9:print " C/F ";hhhmm$:(cftot&);
  158. endp
  159. proc readbal:
  160.     open "clockbal",A,year%,week%,bal&
  161.     last
  162.     bftot&=A.bal&
  163. endp
  164. proc writebal:
  165.     A.bal&=cftot&
  166.     append
  167. endp
  168.  
  169.