home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR10 / DLCALC.ZIP / DLCALC.SCR < prev    next >
Text File  |  1993-10-29  |  4KB  |  130 lines

  1. ;
  2. ; DLCALC.SCR -    File download calculator
  3. ;
  4. ; Written By : Mike Livsey, Icom guru in training...
  5. ; Copywrite (C) 1993 Thunder Lizard Ltd.
  6. ;
  7. ; DLCALC adds up the tagged downloads and prints out a summary report
  8. ; (total Mb to download, smallest file, largest file, est. time to download...)
  9. ; It's SOOOOOOOOOOOO useful, you'll want to send me all your money, or at
  10. ; least a thank you or two.
  11. ;
  12.  
  13. ; Variable Definitions
  14. variable    largest 0       ; Size of largest file being downloaded
  15. variable    largest_file    ; The largest file being downloaded
  16. variable    smallest 99999999   ; Size of smallest file being downloaded
  17. variable    smallest_file   ; The smallest file being downloaded
  18. variable    count 0         ; Number of files being downloaded
  19. variable    sum_bytes 0     ; Total number of bytes being downloaded
  20. variable    est_time        ; Estimated download time
  21. variable    key             ; Stores any key presses
  22. variable    catalog         ; Tagger catalog name
  23. variable    average_cps     ; Average CPS download rate. This is determined
  24.                             ; from acps, which is in the main .ini file.
  25. variable    wnd_title "Mike's Download Calculator"  ; Window title
  26.  
  27. ; Main Logic
  28. loadini $ini_name   ; Load the ini file parameters so I can get access
  29.                     ; to acps (average characters per second)
  30.  
  31. assign catalog "newfiles"     ; Assign the default catalog
  32.  
  33. boxgets catalog 8 wnd_title "Enter the tagger catalog to sum"
  34.  
  35. strblank catalog assign catalog "newfiles"
  36.  
  37. copen catalog   ; Open the user designated catalog.
  38.  
  39. if $errorlevel <> 0
  40.     ; Couldn't open the catalog
  41.     wndopen "Download Calculator" 20 5 60 10
  42.     print "Error: unable to open ^B" catalog
  43.     pause "Press any key to exit..."
  44.     wndclose    
  45.     exit
  46. endif
  47.  
  48. csetsort 1  ; Sort by tag status. This will speed up processing a lot!
  49.  
  50. ; Open a window 
  51. wndopen wnd_title 10 5 70 10
  52. print "Locating tagged files in ^B" catalog "^B. Press ^BESC^B to cancel."
  53.  
  54. assign $KEY_CHECK 0     ; Manually check for pressed keys
  55.  
  56. while 1
  57.     inkey key       ; Check for a key press (user abort)
  58.     if key = "^[" goto aborted      ; ESC was pressed
  59.     cgetrec         ; Grab a record from the database
  60.     if $errorlevel <> 0 break       ; End of catalog 
  61.     if $CTAG_FLD = "T"              ; It's a tagged record
  62.         if $CREC_STAT = "D" continue    ; Ignore deleted records
  63.         printnc "."     ; Make it look like something's happening
  64.         inc count       ; Increment the tagged file count
  65.         ; Grab the record's file size...
  66.         add sum_bytes sum_bytes $CSIZE_FLD
  67.         
  68.         ; Check to see if it's the largest file being downloaded
  69.         if $CSIZE_FLD > largest
  70.             assign largest_file $CNAME_FLD
  71.             assign largest $CSIZE_FLD
  72.         endif
  73.  
  74.         ; Check to see if it's the smallest file being downloaded
  75.         if $CSIZE_FLD < smallest
  76.             assign smallest_file $CNAME_FLD
  77.             assign smallest $CSIZE_FLD
  78.         endif
  79.  
  80.     else
  81.         ; No more tagged records
  82.         print "^MDone!"
  83.         break
  84.     endif
  85.  
  86. endwhile
  87.  
  88. assign $KEY_CHECK 1
  89. cclose
  90.  
  91. if count = 0
  92.     print "No records were tagged."
  93.     pause "^BPress and key to exit..."
  94.     wndclose
  95.     exit
  96. endif
  97.  
  98. ; OK, we've found all the tagged files. Now, try to compute an
  99. ; estimated download time, if possible. This requires that the user
  100. ; fill in acps, the average CPS rate for downloads. If acps is not set,
  101. ; don't attempt the calculation.
  102. assign average_cps *acps
  103. strblank average_cps assign average_cps 0
  104.  
  105. if average_cps <> 0
  106.     mul average_cps average_cps 60      ; Convert CPS to characters per minute
  107.     div est_time sum_bytes average_cps  ; Figure out number of minutes to D/L
  108. else
  109.     assign est_time "N/A"               ; No calculation possible
  110. endif
  111.  
  112. wndopen "Download Statistics" 19 10 61 20
  113. print "Number of files to download: ^B" count
  114. print "Total bytes to download:     ^B" sum_bytes
  115. print "Estimated download time:     ^B" est_time "^B min."
  116. print "Largest file to download:    ^B" largest_file
  117. print "Size of largest file:        ^B" largest
  118. print "Smallest file to download:   ^B" smallest_file
  119. print "Size of smallest file:       ^B" smallest
  120. pause "^BPress any key to exit..."
  121. wndclose
  122. wndclose
  123. return
  124.  
  125. aborted:
  126. print "Download Calculator Aborted!"
  127. pause "^BPress any key to exit..."
  128. wndclose
  129. return
  130.