home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1994 #1
/
monster.zip
/
monster
/
PCBOARD
/
DWNLD20A.ZIP
/
DWNLD.PPS
< prev
next >
Wrap
Text File
|
1994-03-03
|
16KB
|
390 lines
;┌───────────────────────────────────────────────────────────────────────────┐
;│ DWNLD.PPE v2.0 │
;│ PCBOARD 15.1 Download Counter │
;│ │
;│ Written by Steven Hauswirth │
;│ Written in PCBoard Programming Language │
;│ │
;│ "The Power Palace BBS" │
;│ Node 1 - 312-594-0643 - [28.8] - 80386/40 │
;│ │
;│ This PPE is a full screen download counter that informs the user how │
;│ many files, bytes, et cetera they have flagged for download. │
;└───────────────────────────────────────────────────────────────────────────┘
IF (!ANSION()) THEN
PRINT "Enter the filename to Download (Enter)=none"
GOTO EXIT
ENDIF
;┌───────────────────────────────────────────────────────────────────────────┐
;│ Declare Variable Types │
;└───────────────────────────────────────────────────────────────────────────┘
STRING TEMP, Y, FILE_NAME, FLAG_FILE, NO_TIME, FREE_FILE, TEMP_FILE
STRING FLIST_TIME, TEMP_TIME, CONFIG_FILE, HEADER, FOOTER, SPACES
STRING BORDER_COLOR, TITLE_COLOR, BAR_COLOR, CENTER_SPACES
STRING SHOW_NUM, SHOW_SIZE, SHOW_DATE, SHOW_TIME, SHOW_FREE, SHOW_NOTIME
INTEGER COUNT, LOOP, BAT_MIN, BAT_SEC, BAT_TIME, FILE_SEC, FILE_MIN
INTEGER TEMP1, TEMP2, TEMP3, FILE_SIZE, FILE_NUM, AMOUNT_SPACES, SHOW_AMOUNT
INTEGER CONSTANT1, CONSTANT2, FLIST_TOTAL_DATE, FLIST_TOTAL_TIME
INTEGER TEMP_TOTAL_DATE, TEMP_TOTAL_TIME, SKIP_FLAG, EXTRA
DATE FILE_DATE, FLIST_DATE, TEMP_DATE
;┌───────────────────────────────────────────────────────────────────────────┐
;│ Initialize the variables and get the temp and flagged file names │
;└───────────────────────────────────────────────────────────────────────────┘
IF (PCBNODE() = 0) THEN
LET FLAG_FILE = GETENV("PCBDRIVE")+GETENV("PCBDIR")+"\FLIST."
ELSE
LET FLAG_FILE = GETENV("PCBDRIVE")+GETENV("PCBDIR")+"\FLIST."+STRING(PCBNODE())
ENDIF
LET TEMP_FILE = GETENV("PCBDRIVE")+GETENV("PCBDIR")+"\FLIST.TMP"
LET CONFIG_FILE = PPEPATH()+PPENAME()+".CFG"
LET SPACES = " "
LET FILE_NUM = 0
BAT_TIME = 0
TEMP1 = 0
TEMP2 = 0
TEMP3 = 0
EXTRA = 0
LET Y = 1
LET CONSTANT1 = 10000
LET CONSTANT2 = 100
LET AMOUNT_SPACES = 16
LET SHOW_AMOUNT = 2
LET LOOP = 1
;┌───────────────────────────────────────────────────────────────────────────┐
;│ Calculate the time and date of the flagged file list │
;└───────────────────────────────────────────────────────────────────────────┘
:BACK_TO_TOP
FLIST_DATE = FILEINF(FLAG_FILE,2)
LET FLIST_TOTAL_DATE = LEFT(FLIST_DATE,2)*CONSTANT2 + MID(FLIST_DATE,4,2)
FLIST_TIME = FILEINF(FLAG_FILE,3)
LET FLIST_TOTAL_TIME = LEFT(FLIST_TIME,2)*CONSTANT1 + MID(FLIST_TIME,4,2)*CONSTANT2 + RIGHT(FLIST_TIME,2)
;┌───────────────────────────────────────────────────────────────────────────┐
;│ Check to see if they have NOT flagged any files yet for download, or if │
;│ the user has decided not to download the flagged files. │
;└───────────────────────────────────────────────────────────────────────────┘
FOPEN 1,FLAG_FILE,O_RD,S_DN
FDEFIN 1
FSEEK 1,0,SEEK_SET(0)
FOR LOOP = 1 TO 100000
FSEEK 1,66,SEEK_CUR(1)
FDREAD FILE_NAME,13
IF (FERR(1)) BREAK
FSEEK 1,50,SEEK_CUR(1)
NEXT
;┌───────────────────────────────────────────────────────────────────────────┐
;│ If the temp file exists then calculate the time and date of it. Then │
;│ compare it to the flagged file list to see if which is older │
;└───────────────────────────────────────────────────────────────────────────┘
IF (EXIST(TEMP_FILE)) THEN
TEMP_DATE = FILEINF(TEMP_FILE,2)
LET TEMP_TOTAL_DATE = LEFT(TEMP_DATE,2)*CONSTANT2 + MID(TEMP_DATE,4,2)
IF (TEMP_TOTAL_DATE < FLIST_TOTAL_DATE) GOTO SKIP
TEMP_TIME = FILEINF(TEMP_FILE,3)
LET TEMP_TOTAL_TIME = LEFT(TEMP_TIME,2)*CONSTANT1 + MID(TEMP_TIME,4,2)*CONSTANT2 + RIGHT(TEMP_TIME,2)
IF (TEMP_TOTAL_TIME < FLIST_TOTAL_TIME) GOTO SKIP
FOPEN 2, TEMP_FILE, O_RD, S_DN
FGET 2,TEMP1
FCLOSE 2
ELSE GOTO SKIP
ENDIF
IF (TEMP1 > LOOP) THEN
DELETE TEMP_FILE
FOPEN 2, TEMP_FILE, O_WR, S_DN
FPUT 1, LOOP
FCLOSE 2
GOTO SKIP
ENDIF
IF (TEMP1 = LOOP) WAIT
:SKIP
;┌───────────────────────────────────────────────────────────────────────────┐
;│ Create a temp file that will hold the number of files that are flagged │
;│ for download. │
;└───────────────────────────────────────────────────────────────────────────┘
FOPEN 2, TEMP_FILE, O_WR, S_DN
FPUT 2, LOOP
FCLOSE 2
COUNT = LOOP
TEMP1 = 0
TEMP = SCRTEXT(7,17,6,FALSE)
;┌───────────────────────────────────────────────────────────────────────────┐
;│ Read Config File to see if file numbers are to be displayed │
;└───────────────────────────────────────────────────────────────────────────┘
TEMP = TRIM(TEMP," ")
FOPEN 2, CONFIG_FILE, O_RD, S_DN
FGET 2, SHOW_NUM
LET SHOW_NUM = UPPER(SHOW_NUM)
IF (SHOW_NUM = "Y") THEN
SHOW_AMOUNT = SHOW_AMOUNT + 1
ELSE
AMOUNT_SPACES = AMOUNT_SPACES + 4
ENDIF
;┌───────────────────────────────────────────────────────────────────────────┐
;│ Read Config file to see if File Size is to be displayed │
;└───────────────────────────────────────────────────────────────────────────┘
FGET 2, SHOW_SIZE
LET SHOW_SIZE = UPPER(SHOW_SIZE)
IF (SHOW_SIZE = "Y" ) THEN
SHOW_AMOUNT = SHOW_AMOUNT + 1
ELSE
AMOUNT_SPACES = AMOUNT_SPACES + 10
ENDIF
;┌───────────────────────────────────────────────────────────────────────────┐
;│ Read Config File to see if File Date is to be Displayed │
;└───────────────────────────────────────────────────────────────────────────┘
FGET 2, SHOW_DATE
LET SHOW_DATE = UPPER(SHOW_DATE)
IF (SHOW_DATE = "Y" ) THEN
SHOW_AMOUNT = SHOW_AMOUNT + 1
ELSE
AMOUNT_SPACES = AMOUNT_SPACES + 8
ENDIF
;┌───────────────────────────────────────────────────────────────────────────┐
;│ Read Config File to see if File Transfer Time is to be Displayed │
;└───────────────────────────────────────────────────────────────────────────┘
FGET 2, SHOW_TIME
LET SHOW_TIME = UPPER(SHOW_TIME)
IF (SHOW_TIME = "Y" ) THEN
SHOW_AMOUNT = SHOW_AMOUNT + 1
ELSE
AMOUNT_SPACES = AMOUNT_SPACES + 15
ENDIF
;┌───────────────────────────────────────────────────────────────────────────┐
;│ Read Config File to see if Free File Check is to be Displayed │
;└───────────────────────────────────────────────────────────────────────────┘
FGET 2, SHOW_FREE
LET SHOW_FREE = UPPER(SHOW_FREE)
IF (SHOW_FREE = "Y" ) THEN
SHOW_AMOUNT = SHOW_AMOUNT + 1
ELSE
AMOUNT_SPACES = AMOUNT_SPACES + 4
ENDIF
;┌───────────────────────────────────────────────────────────────────────────┐
;│ Read Config File to see if No Time check is to be Displayed │
;└───────────────────────────────────────────────────────────────────────────┘
FGET 2, SHOW_NOTIME
LET SHOW_NOTIME = UPPER(SHOW_NOTIME)
IF (SHOW_NOTIME = "Y" ) THEN
SHOW_AMOUNT = SHOW_AMOUNT + 1
ELSE
AMOUNT_SPACES = AMOUNT_SPACES + 7
ENDIF
LET AMOUNT_SPACES = AMOUNT_SPACES / SHOW_AMOUNT
LET CENTER_SPACES = LEFT(SPACES,AMOUNT_SPACES)
;┌───────────────────────────────────────────────────────────────────────────┐
;│ Check to see if the PPE is already "running", if so then skip header disp │
;└───────────────────────────────────────────────────────────────────────────┘
FGET 2, BORDER_COLOR
IF (TEMP = "Files:") THEN
SKIP_FLAG = 1
ANSIPOS 1,5
GOTO SKIP_HEADER
ENDIF
FGET 2, TITLE_COLOR
FGET 2, BAR_COLOR
FGET 2, HEADER
FGET 2, FOOTER
;┌───────────────────────────────────────────────────────────────────────────┐
;│ Display the header │
;└───────────────────────────────────────────────────────────────────────────┘
IF (GRAFMODE()="R") THEN
PRINTLN ""
PRINTLN "!|1K|*"
ENDIF
PRINTLN "@CLS@"+BORDER_COLOR+" ┌──────────────────────────────────────────────────────────────────────────┐"
LET TEMP = STRIPATX(HEADER)
PRINTLN " │"+LEFT(SPACES,37-(LEN(TEMP)/2))+HEADER+RIGHT(SPACES,37-(LEN(TEMP)/2))+BORDER_COLOR+"│"
PRINT " │"+TITLE_COLOR
;┌───────────────────────────────────────────────────────────────────────────┐
;│ Display the sysop configurable file info │
;└───────────────────────────────────────────────────────────────────────────┘
IF (SHOW_NUM = "Y" ) PRINT CENTER_SPACES+"@X0FNum"
PRINT CENTER_SPACES+" @X0FFilename "+CENTER_SPACES
IF (SHOW_SIZE = "Y") PRINT " Size "+CENTER_SPACES
IF (SHOW_DATE = "Y") PRINT " Date "+CENTER_SPACES
IF (SHOW_TIME = "Y") PRINT " Transfer Time "+CENTER_SPACES
IF (SHOW_FREE = "Y") PRINT "Free"+CENTER_SPACES
IF (SHOW_NOTIME = "Y") PRINT "No Time"
ANSIPOS 78,3
PRINTLN BORDER_COLOR+"│"
;┌───────────────────────────────────────────────────────────────────────────┐
;│ Display the bullet bar │
;└───────────────────────────────────────────────────────────────────────────┘
PRINT " │"+BAR_COLOR
IF (SHOW_NUM = "Y" ) PRINT LEFT(SPACES,AMOUNT_SPACES-1)+"────"
PRINT CENTER_SPACES+"────────────"+CENTER_SPACES
IF (SHOW_SIZE = "Y") PRINT "──────────"+CENTER_SPACES
IF (SHOW_DATE = "Y") PRINT "────────"+CENTER_SPACES
IF (SHOW_TIME = "Y") PRINT "───────────────"+CENTER_SPACES
IF (SHOW_FREE = "Y") PRINT "────"+CENTER_SPACES
IF (SHOW_NOTIME = "Y") PRINT "───────"
ANSIPOS 78,4
PRINTLN BORDER_COLOR+"│"
;┌───────────────────────────────────────────────────────────────────────────┐
;│ Since there are files already flagged for download. Find out how many. │
;│ If there are more then 10 then position display to only display the last │
;│ ten of them. │
;└───────────────────────────────────────────────────────────────────────────┘
:SKIP_HEADER
FCLOSE 2
FSEEK 1,0,SEEK_SET(0)
IF (COUNT>10) THEN
FOR LOOP = 1 TO (COUNT-10)
FSEEK 1,83,SEEK_CUR(1)
FDREAD TEMP,1
IF (ASC(TEMP)!=0) TEMP1 = ASC(TEMP)
FDREAD TEMP,1
IF (ASC(TEMP)!=0) TEMP2 = 256*ASC(TEMP)
FDREAD TEMP,1
IF (ASC(TEMP)!=0) TEMP3 =65536*ASC(TEMP)
BAT_TIME = BAT_TIME + TEMP1 + TEMP2 + TEMP3
FSEEK 1,43,SEEK_CUR(1)
NEXT
ELSE COUNT = 10
ENDIF
LET Y = COUNT-9
;┌───────────────────────────────────────────────────────────────────────────┐
;│ Display the file name, bytes, and transfer time for all the files flagged │
;└───────────────────────────────────────────────────────────────────────────┘
FOR LOOP= 1 TO COUNT
TEMP1 = 0
TEMP2 = 0
TEMP3 = 0
FDREAD TEMP,66
IF (FERR(1)) BREAK
TEMP = TRIM(TEMP," ")
FILE_DATE = FILEINF(TEMP,2)
FDREAD FILE_NAME,13
FDREAD TEMP,1
IF (ASC(TEMP)!=0) TEMP1 = ASC(TEMP)
FDREAD TEMP,1
IF (ASC(TEMP)!=0) TEMP2 = 256*ASC(TEMP)
FDREAD TEMP,1
IF (ASC(TEMP)!=0) TEMP3 =65536*ASC(TEMP)
FILE_SIZE = TEMP1+TEMP2+TEMP3
TEMP1 = 0
TEMP2 = 0
TEMP3 = 0
FSEEK 1,1,SEEK_CUR(1)
FDREAD TEMP,1
IF (ASC(TEMP)!=0) TEMP1 = ASC(TEMP)
FDREAD TEMP,1
IF (ASC(TEMP)!=0) TEMP2 = 256*ASC(TEMP)
FDREAD TEMP,1
IF (ASC(TEMP)!=0) TEMP3 =65536*ASC(TEMP)
FILE_SEC = TEMP1 + TEMP2 + TEMP3
BAT_TIME = BAT_TIME + FILE_SEC
FSEEK 1,9,SEEK_CUR(1)
FDREAD FREE_FILE,1
FDREAD NO_TIME,1
FSEEK 1,32,SEEK_CUR(1)
FILE_MIN = FILE_SEC/60
FILE_SEC = FILE_SEC - FILE_MIN*60
PRINT BORDER_COLOR+" │@X0B"
IF (SHOW_NUM = "Y" ) PRINT CENTER_SPACES+LEFT(SPACES,2-LEN(STRING(Y)))+STRING(Y)+" "
PRINT CENTER_SPACES+"@X0F"+LEFT(SPACES,12-LEN(FILE_NAME))+FILE_NAME+CENTER_SPACES
IF (SHOW_SIZE = "Y") PRINT LEFT(SPACES,10-LEN(STRING(FILE_SIZE)))+STRING(FILE_SIZE)+CENTER_SPACES
IF (SHOW_DATE = "Y") PRINT STRING(FILE_DATE)+CENTER_SPACES
IF (SHOW_TIME = "Y") PRINT LEFT(SPACES,4-LEN(STRING(FILE_MIN)))+STRING(FILE_MIN)+" @X07min@X0F"+LEFT(" ",3-LEN(STRING(FILE_SEC)))+STRING(FILE_SEC)+" @X07sec"+CENTER_SPACES
IF (SHOW_FREE = "Y") THEN
IF (ASC(FREE_FILE)=1) THEN
PRINT " @X0CY"
ELSE PRINT " @X0EN"
ENDIF
PRINT CENTER_SPACES
ENDIF
IF (SHOW_NOTIME = "Y") THEN
IF (ASC(NO_TIME)=1) THEN
PRINT " @X0CY"
ELSE PRINT " @X0EN"
ENDIF
ENDIF
ANSIPOS 78,4+LOOP
PRINTLN BORDER_COLOR+"│"
ANSIPOS 1,5+LOOP
INC Y
NEXT
;┌────────────────────────────────────────────────────────────────────────────┐
;│ Display with blank lines to fill the screen to ten file placements listed │
;└────────────────────────────────────────────────────────────────────────────┘
FOR LOOP = LOOP TO 10
PRINT BORDER_COLOR+" │@X0B"
IF (SHOW_NUM = "Y" ) PRINT CENTER_SPACES+LEFT(SPACES,2-LEN(STRING(Y)))+STRING(Y)+" "
PRINT CENTER_SPACES+" @X0F"
IF (SHOW_SIZE = "Y") PRINT CENTER_SPACES+" 0"
IF (SHOW_DATE = "Y") PRINT CENTER_SPACES+"00-00-00"
IF (SHOW_TIME = "Y") PRINT CENTER_SPACES+" 0 @X07min@X0F 0 @X07sec"
ANSIPOS 78,4+LOOP
PRINTLN BORDER_COLOR+"│"
INC Y
IF (SKIP_FLAG = 1) THEN
ANSIPOS 1,17
GOTO SKIP_FOOTER
ENDIF
NEXT
;┌───────────────────────────────────────────────────────────────────────────┐
;│ Display the footer of the dispay │
;└───────────────────────────────────────────────────────────────────────────┘
PRINTLN " │ │"
LET TEMP = STRIPATX(FOOTER)
PRINTLN " │"+LEFT(SPACES,37-(LEN(TEMP)/2))+FOOTER+RIGHT(SPACES,37-(LEN(TEMP)/2))+"│"
:SKIP_FOOTER
PRINT " │ @X07Files: @X0F@FFILES:3@ @X07Size (bytes): @X0F@FBYTES:12@ @X07Estimated time: @X0F"
;┌───────────────────────────────────────────────────────────────────────────┐
;│ Calculate the BATCH transfer time from the BATCH bytes listed on screen │
;│ taking into account local logons and error correcting modems. │
;└───────────────────────────────────────────────────────────────────────────┘
LET FILE_NUM = S2I(TRIM(SCRTEXT(14,17,2,FALSE)," "),10)
BAT_MIN = BAT_TIME/60
BAT_SEC = BAT_TIME - BAT_MIN*60
PRINT STRING(BAT_MIN)+" @X07min"+" @X0F"+STRING(BAT_SEC)+" @X07sec"+BORDER_COLOR
ANSIPOS 78,17
PRINTLN "│"
IF (SKIP_FLAG = 1) THEN
ANSIPOS 1,19
GOTO SKIP_BOTTOM
ENDIF
PRINTLN " └──────────────────────────────────────────────────────────────────────────┘"
:SKIP_BOTTOM
PRINTLN " @X0FEnter the filename to Download (Enter)=none @X082.0"
CLREOL
PRINTLN
PRINTLN
CLREOL
;┌───────────────────────────────────────────────────────────────────────────┐
;│ Position cursor on the screen and ask for file name. Then stuff it into │
;│ keyboard buffer and exit │
;└───────────────────────────────────────────────────────────────────────────┘
IF (FILE_NUM > 9) FILE_NUM = 9
IF (SHOW_NUM = "Y") EXTRA = 3 + AMOUNT_SPACES
ANSIPOS 4+AMOUNT_SPACES+EXTRA,5+FILE_NUM
PRINT " "
ANSIPOS 4+AMOUNT_SPACES+EXTRA,5+FILE_NUM
LET FILE_NAME = ""
INPUTSTR "_",file_name,@X07,12,MASK_FILE()+"*?",UPCASE
ANSIPOS 1,19
FILE_NAME=TRIM(FILE_NAME," ")
IF (LEN(file_name) = 0) file_name = CHR(13)
KBDSTUFF file_name
:EXIT
END