home *** CD-ROM | disk | FTP | other *** search
/ Meeting Pearls 3 / Meeting_Pearls_III.iso / Pearls / comm / Fido / Spot / Rexx / WriteStat.spot < prev   
Text File  |  1993-11-11  |  11KB  |  368 lines

  1. /* Stats on writing                */
  2. /* Author : Philippe Van Der Gucht */
  3. /* Date   : 8/8/1993               */
  4. /* Version: 1.0                    */
  5. /* FIDO   : 2:291/708.15           */
  6.  
  7. Address Spot
  8. Options results
  9.  
  10. 'requeststring TITLE "Select a user in current message-base"'
  11. naam=RESULT
  12. if naam == 'RESULT' then exit
  13. 'messagelist'
  14. 'include FROM "'naam'" NOREQ NOGUI'
  15. 'getnumselected'
  16. totaal=RESULT
  17. if totaal == 0 then do 
  18.    'requestnotify PROMPT "Name not found."'
  19.    exit
  20. end
  21. 'messages'
  22. 'firstmessage'
  23. 'getfrom'
  24. eerst_nm=RESULT
  25. if naam ~= eerst_nm then 'nextmarked'
  26. CR='0d'x
  27. LF='0a'x
  28. tel=0
  29. einde=0
  30. say totaal
  31. 'progressopen TITLE "Reading dates..."'
  32. prg=RESULT
  33. do while einde == 0
  34.    'progressupdate' prg tel totaal
  35.    res2=RC
  36.    if res2 == 5 then do
  37.       'progressclose' prg
  38.       'excludeflag ALL'
  39.       exit
  40.    end
  41.    'getdatewritten'
  42.    datum.tel=RESULT
  43.    tel=tel+1
  44.    'nextmarked'
  45.    einde=RC
  46. end
  47. 'progressclose' prg
  48. 'excludeflag ALL'
  49. address command 'Date >t:date.temp'
  50. Datum=Get_current_date()
  51. address command 'Delete >NIL: t:date.temp'
  52. call Get_dates_right()
  53. 'requestresponse TITLE "Choose time-basis:" PROMPT " Day   - Stats of the last 7 days 'cr' Week  - Stats of the last 4 weeks" GADGETS "_Day|_Week|_Cancel"'
  54. res2=RC 
  55. select 
  56.    when res2 == 1 then call Make_day_stats()
  57.    when res2 == 2 then call Make_week_stats()
  58.    otherwise exit
  59. end
  60. if (res2 == 1) | (res2 == 2) then do
  61.    'requestresponse TITLE "Include result:" PROMPT " File    - Results will be saved in file 'cr' Message - Write result in message base" GADGETS "File|_Message|_Cancel"'
  62.    res2=RC
  63.    select 
  64.       when res2 == 1 then call Save_to_file()
  65.       when res2 == 2 then call Save_to_message()
  66.       otherwise NOP
  67.    end
  68. end
  69. exit
  70.  
  71. Save_to_file:
  72.    'requestfile TITLE "Save file:" PATH "SYS:"'
  73.    file_nm=RESULT
  74.    address command 'rename t:graf.temp "'file_nm'"'
  75.    address command 'Delete >NIL: t:graf.temp'
  76. return
  77.  
  78. Save_to_message:
  79.    'write FILE "t:graf.temp"'
  80.    address command 'Delete >NIL: t:graf.temp'
  81. return   
  82.  
  83. Make_week_stats:
  84.    Datum=right(Datum,4) || substr(Datum,4,2) || left(Datum,2)
  85.    teller=tel-1
  86.    tel2=0
  87.    Nw_datum=Datum
  88.    do while (tel2 <= 30) & (teller >= 0) 
  89.       Nw_datum=Check_date(Nw_datum)
  90.       Nw_datum.tel2=Nw_datum
  91.       C_datum.tel2=0
  92.       do while Nw_datum == datum.teller
  93.          teller=teller-1
  94.          if teller < 0 then leave
  95.          C_datum.tel2=C_datum.tel2+1
  96.       end
  97.       say C_datum.tel2 Nw_datum 
  98.       tel2=tel2+1
  99.       Nw_datum=Nw_datum-1
  100.    end
  101.    tel=0
  102.    groot=0   
  103.    do while (tel <= 30) & (tel <= tel2-1) 
  104.       if C_datum.tel >= groot then groot=C_datum.tel
  105.       tel=tel+1
  106.    end
  107.    say groot
  108.    /* Verhoudingsgetal (R van 3!) naar 15 voor graph te verkleinen */
  109.    index=15/groot
  110.    tel=0
  111.    do while (tel <= 30) & (tel <= tel2-1)
  112.       graf.tel=round(C_datum.tel*index)
  113.       tel=tel+1
  114.    end
  115.    call open(graph,'t:graf.temp','W')
  116.    call Print_info()
  117.    call writeln(graph,groot)
  118.    tel3=15
  119.    do while tel3 >= 0 
  120.       call writech(graph,' | ')
  121.       tel=0 
  122.       spat=1
  123.       do while (tel <= 30) & (tel <= tel2-1) 
  124.          if graf.tel >= tel3 then do
  125.             call writech(graph,copies(' ',2*spat-1) || '')
  126.             spat=1
  127.          end
  128.          else spat=spat+1   
  129.          tel=tel+1
  130.       end
  131.       tel3=tel3-1
  132.       call writech(graph,LF)
  133.    end
  134.    call writeln(graph,' +' || copies('-',74))
  135.    tel=0
  136.    call writech(graph,'    ')
  137.    do while (tel <= 30) & (tel <= tel2-1)
  138.       call writech(graph,right(Nw_datum.tel,2))
  139.       tel=tel+1
  140.    end 
  141.    call writeln(graph,' ')
  142.    call writeln(graph,' ')
  143.    call writeln(graph,naam 'wrote' totaal 'messages.')
  144.    call writeln(graph,'Average messages/day:' round(totaal/(tel2-1)))
  145.    call close(graph)  
  146. return
  147.      
  148. Print_info:
  149.    call writeln(graph,'       +-Info---------------------------------------------+')
  150.    call writeln(graph,'       | Writing stats script by Philippe Van Der Gucht   |')
  151.    call writeln(graph,'       +-----------------FIDO: 2:291/708.15---------------+')
  152.    call writeln(graph,'       | The chart displays the amount of messages the    |')
  153.    call writeln(graph,'       | writer wrote a particular day. Have fun! :)      |')
  154.    call writeln(graph,'       +--------------------------------------------------+')
  155.    call writeln(graph,' ')
  156. return
  157.  
  158. Make_day_stats:
  159.    Datum=right(Datum,4) || substr(Datum,4,2) || left(Datum,2)
  160.    teller=tel-1
  161.    tel2=0
  162.    Nw_datum=Datum
  163.    do while tel2 <= 6 
  164.       Nw_datum=Check_date(Nw_datum)
  165.       Nw_datum.tel2=Nw_datum
  166.       C_datum.tel2=0
  167.       do while Nw_datum == datum.teller
  168.          teller=teller-1
  169.          C_datum.tel2=C_datum.tel2+1
  170.       end
  171.       say C_datum.tel2 Nw_datum
  172.       tel2=tel2+1
  173.       Nw_datum=Nw_datum-1
  174.    end
  175.    tel2=0
  176.    groot=0   
  177.    do while tel2 <= 6
  178.       if C_datum.tel2 >= groot then groot=C_datum.tel2
  179.       tel2=tel2+1
  180.    end
  181.    say groot
  182.    index=15/groot
  183.    tel2=0
  184.    do while tel2 <= 6
  185.       graf.tel2=round(C_datum.tel2*index)
  186.       tel2=tel2+1
  187.    end
  188.    call open(graph,'t:graf.temp','W')
  189.    call Print_info()
  190.    call writeln(graph,groot)
  191.    tel3=15
  192.    do while tel3 >= 0
  193.       call writech(graph,' | ')
  194.       tel2=0 
  195.       spat=1
  196.       do while tel2 <= 6
  197.          if graf.tel2 >= tel3 then do
  198.             call writech(graph,copies(' ',7*spat-1) || '')
  199.             spat=1
  200.          end
  201.          else spat=spat+1   
  202.          tel2=tel2+1
  203.       end
  204.       tel3=tel3-1
  205.       call writech(graph,LF)
  206.    end
  207.    call writeln(graph,' +' || copies('-',60))
  208.    tel2=0
  209.    call writech(graph,'         ')
  210.    do while tel2 <= 6
  211.       call writech(graph,right(Nw_datum.tel2,4) || '   ')
  212.       tel2=tel2+1
  213.    end
  214.    call writeln(graph,' ')
  215.    call writeln(graph,' ')
  216.    call writeln(graph,naam 'wrote' totaal 'messages')
  217.    call writeln(graph,'Average message/day:' round(totaal/(tel2-1)))
  218.    call close(graph)  
  219. return
  220.  
  221. round:
  222.    arg reel
  223.    posi=pos('.',reel)
  224.    if posi ~= 0 then do
  225.       get1=left(reel,posi-1)
  226.       get2=substr(reel,posi+1,1)
  227.       if get2 >= 5 then return get1+1
  228.       else return get1
  229.    end
  230. return reel
  231.    
  232. Check_date:
  233.    arg dat
  234.    if right(dat,2) == '00' then do
  235.       select
  236.          when substr(dat,5,2) == '01' then do
  237.             dat=(left(dat,4)-1) || '12' || '31'
  238.             return dat
  239.          end
  240.          when substr(dat,5,2) == '02' then do
  241.             dat=left(dat,4) || '01' || '31'
  242.             return dat
  243.          end
  244.          when substr(dat,5,2) == '03' then do
  245.             dat=left(dat,4) || '02' || '28'
  246.             return dat
  247.          end 
  248.          when substr(dat,5,2) == '04' then do
  249.             dat=left(dat,4) || '03' || '31'
  250.             return dat
  251.          end         
  252.          when substr(dat,5,2) == '05' then do
  253.             dat=left(dat,4) || '04' || '30'
  254.             return dat
  255.          end
  256.          when substr(dat,5,2) == '06' then do
  257.             dat=left(dat,4) || '05' || '31'
  258.             return dat
  259.          end
  260.          when substr(dat,5,2) == '07' then do
  261.             dat=left(dat,4) || '06' || '30'
  262.             return dat
  263.          end
  264.          when substr(dat,5,2) == '08' then do
  265.             dat=left(dat,4) || '07' || '31'
  266.             return dat
  267.          end
  268.          when substr(dat,5,2) == '09' then do
  269.             dat=left(dat,4) || '08' || '31'
  270.             return dat
  271.          end
  272.          when substr(dat,5,2) == '10' then do
  273.             dat=left(dat,4) || '09' || '30'
  274.             return dat
  275.          end
  276.          when substr(dat,5,2) == '11' then do
  277.             dat=left(dat,4) || '10' || '31'
  278.             return dat
  279.          end
  280.          when substr(dat,5,2) == '12' then do
  281.             dat=left(dat,4) || '11' || '30'
  282.             return dat
  283.          end
  284.       end
  285.    end
  286.    else return dat
  287. return
  288.  
  289. Conv_date:
  290.    arg dat
  291.    dag=right(dat,2)
  292.    maand=substr(dat,5,2)
  293.    jaar=left(dat,4)
  294. return      
  295.  
  296. Get_dates_right:
  297.    teller=0
  298.    do while teller <= (tel-1)
  299.       O_aan_maand=0
  300.       O_aan_dag=0
  301.       posi=pos('.',datum.teller)
  302.       if posi == 2 then O_aan_dag=1
  303.       posi=pos('.',datum.teller,4)
  304.       if (O_aan_dag == 1) & (posi == 4) then O_aan_maand=1
  305.       if (O_aan_dag ~= 1) & (posi == 5) then O_aan_maand=1
  306.       if O_aan_dag == 1 then datum.teller='0' || datum.teller
  307.       if O_aan_maand == 1 then datum.teller=insert('0',datum.teller,3)
  308.       datum.teller=right(datum.teller,4) || substr(datum.teller,4,2) || left(datum.teller,2)
  309.       teller=teller+1
  310.    end
  311. return      
  312.  
  313. Get_current_date:
  314.    call open(date_file,'t:date.temp','R')
  315.    date_str=readln(date_file)
  316.    call close(date_file)
  317.    select
  318.       when pos('Jan',date_str) ~= 0 then do
  319.          posit=pos('Jan',date_str)
  320.          return substr(date_str,posit-3,2) || '.' || '01.' || '19' || substr(date_str,posit+4,2)
  321.       end
  322.       when pos('Feb',date_str) ~= 0 then do
  323.          posit=pos('Feb',date_str)
  324.          return substr(date_str,posit-3,2) || '.' || '02.' || '19' || substr(date_str,posit+4,2)
  325.       end
  326.       when pos('Mar',date_str) ~= 0 then do
  327.          posit=pos('Mar',date_str)
  328.          return substr(date_str,posit-3,2) || '.' || '03.' || '19' || substr(date_str,posit+4,2)
  329.       end
  330.       when pos('Apr',date_str) ~= 0 then do
  331.          posit=pos('Apr',date_str)
  332.          return substr(date_str,posit-3,2) || '.' || '04.' || '19' || substr(date_str,posit+4,2)
  333.       end
  334.       when pos('May',date_str) ~= 0 then do
  335.          posit=pos('May',date_str)
  336.          return substr(date_str,posit-3,2) || '.' || '05.' || '19' || substr(date_str,posit+4,2)
  337.       end
  338.       when pos('Jun',date_str) ~= 0 then do
  339.          posit=pos('Jun',date_str)
  340.          return substr(date_str,posit-3,2) || '.' || '06.' || '19' || substr(date_str,posit+4,2)
  341.       end
  342.       when pos('Jul',date_str) ~= 0 then do
  343.          posit=pos('Jul',date_str)
  344.          return substr(date_str,posit-3,2) || '.' || '07.' || '19' || substr(date_str,posit+4,2)
  345.       end
  346.       when pos('Aug',date_str) ~= 0 then do
  347.          posit=pos('Aug',date_str)
  348.          return substr(date_str,posit-3,2) || '.' || '08.' || '19' || substr(date_str,posit+4,2)
  349.       end
  350.       when pos('Sep',date_str) ~= 0 then do
  351.          posit=pos('Sep',date_str)
  352.          return substr(date_str,posit-3,2) || '.' || '09.' || '19' || substr(date_str,posit+4,2)
  353.       end
  354.       when pos('Oct',date_str) ~= 0 then do
  355.          posit=pos('Oct',date_str)
  356.          return substr(date_str,posit-3,2) || '.' || '10.' || '19' || substr(date_str,posit+4,2)
  357.       end
  358.       when pos('Nov',date_str) ~= 0 then do
  359.          posit=pos('Nov',date_str)
  360.          return substr(date_str,posit-3,2) || '.' || '11.' || '19' || substr(date_str,posit+4,2)
  361.       end
  362.       when pos('Dec',date_str) ~= 0 then do
  363.          posit=pos('Dec',date_str)
  364.          return substr(date_str,posit-3,2) || '.' || '12.' || '19' || substr(date_str,posit+4,2)
  365.       end
  366.    end
  367. return
  368.