home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Current Shareware 1994 January
/
SHAR194.ISO
/
modem
/
dlcalc.zip
/
DLCALC.SCR
< prev
next >
Wrap
Text File
|
1993-10-29
|
4KB
|
130 lines
;
; DLCALC.SCR - File download calculator
;
; Written By : Mike Livsey, Icom guru in training...
; Copywrite (C) 1993 Thunder Lizard Ltd.
;
; DLCALC adds up the tagged downloads and prints out a summary report
; (total Mb to download, smallest file, largest file, est. time to download...)
; It's SOOOOOOOOOOOO useful, you'll want to send me all your money, or at
; least a thank you or two.
;
; Variable Definitions
variable largest 0 ; Size of largest file being downloaded
variable largest_file ; The largest file being downloaded
variable smallest 99999999 ; Size of smallest file being downloaded
variable smallest_file ; The smallest file being downloaded
variable count 0 ; Number of files being downloaded
variable sum_bytes 0 ; Total number of bytes being downloaded
variable est_time ; Estimated download time
variable key ; Stores any key presses
variable catalog ; Tagger catalog name
variable average_cps ; Average CPS download rate. This is determined
; from acps, which is in the main .ini file.
variable wnd_title "Mike's Download Calculator" ; Window title
; Main Logic
loadini $ini_name ; Load the ini file parameters so I can get access
; to acps (average characters per second)
assign catalog "newfiles" ; Assign the default catalog
boxgets catalog 8 wnd_title "Enter the tagger catalog to sum"
strblank catalog assign catalog "newfiles"
copen catalog ; Open the user designated catalog.
if $errorlevel <> 0
; Couldn't open the catalog
wndopen "Download Calculator" 20 5 60 10
print "Error: unable to open ^B" catalog
pause "Press any key to exit..."
wndclose
exit
endif
csetsort 1 ; Sort by tag status. This will speed up processing a lot!
; Open a window
wndopen wnd_title 10 5 70 10
print "Locating tagged files in ^B" catalog "^B. Press ^BESC^B to cancel."
assign $KEY_CHECK 0 ; Manually check for pressed keys
while 1
inkey key ; Check for a key press (user abort)
if key = "^[" goto aborted ; ESC was pressed
cgetrec ; Grab a record from the database
if $errorlevel <> 0 break ; End of catalog
if $CTAG_FLD = "T" ; It's a tagged record
if $CREC_STAT = "D" continue ; Ignore deleted records
printnc "." ; Make it look like something's happening
inc count ; Increment the tagged file count
; Grab the record's file size...
add sum_bytes sum_bytes $CSIZE_FLD
; Check to see if it's the largest file being downloaded
if $CSIZE_FLD > largest
assign largest_file $CNAME_FLD
assign largest $CSIZE_FLD
endif
; Check to see if it's the smallest file being downloaded
if $CSIZE_FLD < smallest
assign smallest_file $CNAME_FLD
assign smallest $CSIZE_FLD
endif
else
; No more tagged records
print "^MDone!"
break
endif
endwhile
assign $KEY_CHECK 1
cclose
if count = 0
print "No records were tagged."
pause "^BPress and key to exit..."
wndclose
exit
endif
; OK, we've found all the tagged files. Now, try to compute an
; estimated download time, if possible. This requires that the user
; fill in acps, the average CPS rate for downloads. If acps is not set,
; don't attempt the calculation.
assign average_cps *acps
strblank average_cps assign average_cps 0
if average_cps <> 0
mul average_cps average_cps 60 ; Convert CPS to characters per minute
div est_time sum_bytes average_cps ; Figure out number of minutes to D/L
else
assign est_time "N/A" ; No calculation possible
endif
wndopen "Download Statistics" 19 10 61 20
print "Number of files to download: ^B" count
print "Total bytes to download: ^B" sum_bytes
print "Estimated download time: ^B" est_time "^B min."
print "Largest file to download: ^B" largest_file
print "Size of largest file: ^B" largest
print "Smallest file to download: ^B" smallest_file
print "Size of smallest file: ^B" smallest
pause "^BPress any key to exit..."
wndclose
wndclose
return
aborted:
print "Download Calculator Aborted!"
pause "^BPress any key to exit..."
wndclose
return