home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / PCBOARD / DLPRM100.ZIP / DLPROMPT.PPS < prev    next >
Text File  |  1994-03-13  |  10KB  |  415 lines

  1. ;** Wishlist
  2.  
  3. ; - Get ride of the @WAIT@ inbetween each file.  Write the docs and tell users
  4. ;   that they have to make sure their prompts (which ones?) are up-to-date.
  5. ;   Perhaps I could even ship with some samples.
  6.  
  7. ' Does the user have ANSI?  If not, display a standard download prompt
  8. ' (via the DLPROMPT file) and end the execution of the PPE.
  9.  
  10. GETUSER
  11.  
  12. BOOLEAN ExpertSkip, SysOpSkip
  13. STRING  Parameter
  14.  
  15. ExpertSkip = FALSE
  16. SysOpSkip  = FALSE
  17.  
  18. Parameter = GETTOKEN()                ; Get the first command line parameter
  19.  
  20. ' Now that we have a command line parameter, check to see if it is a known
  21. ' switch.  If so, set the appropriate Boolean flag.  Continue to check
  22. ' parameters, until there are no more to process (LEN Parameter = 0).
  23. '
  24. ' NOTE:  Line 8 of PCBOARD.DAT contains the minimum security level PCBoard
  25. '        considers to be a SysOp.
  26.  
  27. WHILE (LEN(Parameter) != 0) DO
  28.    IF (MID(Parameter,2,2) = "SY" & CURSEC() >= READLINE(PCBDAT(),8)) SysOpSkip  = TRUE
  29.    IF (MID(Parameter,2,2) = "EX" & U_EXPERT) ExpertSkip = TRUE
  30.    Parameter = GETTOKEN()
  31. ENDWHILE
  32.  
  33. ' Check to see if we should display the normal prompt rather than the
  34. ' full-screen download prompt.  Examples of why the normal prompt should
  35. ' be displayed:
  36. '
  37. '    * User is not capable of ANSI
  38. '    * PPE is configured to skip for experts or SysOps.
  39.  
  40. IF (! ANSION() | ExpertSkip | SysOpSkip) THEN
  41.    DISPFILE PPEPATH() + "DLPROMPT", LANG
  42.    END
  43. ENDIF
  44.  
  45. ' Define the rest of the variables used throughout the PPE
  46.  
  47. STRING   LocOfFLIST
  48. STRING   TimeText
  49. LONG     ReadSize
  50. LONG     ReadSeconds
  51. BIGSTR   DLFileName
  52. STRING   Response
  53. INTEGER  Counter
  54. INTEGER  LineNo
  55. INTEGER  RecSize
  56. STRING   Filename(5)
  57. LONG     Size(5)
  58. LONG     Seconds(5)
  59. BOOLEAN  Free(5)
  60. BOOLEAN  NoTime(5)
  61. UNSIGNED BatchSeconds
  62. UNSIGNED BatchSize
  63. INTEGER  SizeOfFLIST
  64. INT      EndCounter
  65. BYTE     NumHours
  66. BYTE     NumMin
  67. BOOLEAN  MoreThanFiveFiles
  68. STRING   Files2DL
  69. STRING   ESC
  70.  
  71. ' Check for the existance of the semaphor file.  If it exists, delete it.
  72.  
  73. IF (EXIST("DL"+STRING(PCBNODE())+".$$$")) THEN
  74.    DELETE "DL"+STRING(PCBNODE())+".$$$"
  75.  
  76.    'If the cursor is at column 1 of the 22nd line, clear the screen.
  77.  
  78.    IF (GETX()=1 & GETY()=22) THEN
  79.       CLS
  80.  
  81.    'Since the cursor is not at column 1 - row 22, go to the beginning
  82.    'of the line, display "Press ENTER to Continue" prompt and clear the
  83.    'screen.
  84.  
  85.    ELSE
  86.       ANSIPOS 1, GETY()
  87.       WAIT
  88.       CLS
  89.    ENDIF
  90.  
  91.    ' If the semaphor file was not found, clear the screen for good
  92.    ' measure.
  93.  
  94. ELSE
  95.    CLS
  96. ENDIF
  97.  
  98. ' Define the ESC character.  We could always use CHR(27), but ESC is almost
  99. ' always more readable at the source level.
  100.  
  101. ESC        = CHR(27)
  102.  
  103. ' The FLIST file is the data file PCBoard uses to keep track of which files
  104. ' are flagged for download.  Figure out what the filename will be for the
  105. ' FLIST file.  Single node systems use just the name "FLIST".  Multiple node
  106. ' systems use FLIST.### where ### is the node number.
  107.  
  108. IF (READLINE(PCBDAT(),90) = "-1") THEN
  109.    LocOfFLIST = "FLIST." + string(pcbnode())
  110. ELSE
  111.    LocOfFLIST = "FLIST."
  112. ENDIF
  113.  
  114. ' The size of each record in the FLIST file is 129 bytes.  With most files,
  115. ' the size of the file could be determined with the FILEINF function.
  116. ' Because the FLIST stats are never updated in the FAT, we have to be more
  117. ' creative.  Using the FLAGCNT() function we know how many files are flagged
  118. ' for download.  Multiplying this number by 129 will give the true size
  119. ' of the FLIST file.
  120.  
  121. RecSize    = 129
  122. SizeOfFLIST= 129 * FLAGCNT()
  123.  
  124. ' Open up the FLIST file twice.  By opening up the FLIST on two channels,
  125. ' more efficiency is gained in the file access.
  126.  
  127. IF (EXIST(LocOfFLIST)) THEN
  128.    FOPEN 1, LocOfFLIST, O_RW, S_DN
  129.    FOPEN 2, LocOfFLIST, O_RW, S_DN
  130. ENDIF
  131.  
  132. ' Display the infamous DLPROMPT box.  This screen can be ANSI, RIP, or just
  133. ' plain ASCII.
  134.  
  135. DISPFILE PPEPATH() + "DLBOX", GRAPH
  136.  
  137. ' Check to see what mode the user is in and display the file statistics
  138. ' based on the mode (ANSI is a shorter screen than RIP).
  139.  
  140. IF (GRAFMODE() = "R") THEN
  141.    GOSUB DisplayRIP
  142. ELSE
  143.    GOSUB DisplayANSI
  144. ENDIF
  145.  
  146. 'Close the two FLIST file channels opened.
  147.  
  148. FCLOSE 1
  149. FCLOSE 2
  150.  
  151. ' That is all folks.
  152.  
  153. END
  154.  
  155.  
  156. ;****************************************************************************
  157. ;****************************************************************************
  158.  
  159. ;                        S  U  B  R  O  U  T  I  N  E  S
  160.  
  161. ;****************************************************************************
  162. ;****************************************************************************
  163.  
  164.  
  165. :DisplayANSI
  166.  
  167. ' Set the cursor color to white.  Why I did it in ANSI instead of @X codes,
  168. ' I have not been able to determine yet.  :)
  169.  
  170. PRINT esc + "[37;1;m"
  171.  
  172. ' Let's read the last five files in the batch list and gather the statistics
  173. ' on them.
  174.  
  175. GOSUB ReadLastFive
  176.  
  177. ' Reposition the cursor to column 1, row 12.
  178.  
  179. ANSIPOS 1,12
  180.  
  181. ' Using the PrintEntry subroutine, display the statistics for each of the
  182. ' last five files in the batch.
  183.  
  184. FOR Counter = 1 TO 5
  185.    PRINT ESC + "[4C"
  186.    PUSH Counter
  187.    GOSUB PrintEntry
  188. NEXT
  189.  
  190. ' Using the EstimateBatch subroutine, get the totals for the entire batch
  191. ' transfer.
  192.  
  193. GOSUB EstimateBatch
  194.  
  195. ' Now display those totals on the screen.
  196.  
  197. ANSIPOS 12,20
  198. OPTEXT FLAGCNT()
  199. PRINT "@X0F", "@OPTEXT:4R@"
  200.  
  201. PRINT ESC + "[17C"
  202. OPTEXT BatchSize
  203. PRINT "@X0F", "@OPTEXT:10@"
  204.  
  205. PUSH  BatchSeconds
  206. GOSUB Time2Text
  207.  
  208. PRINT ESC + "[19C"
  209. PRINT "@X0F", TimeText
  210.  
  211. ;ANSIPOS 24,2
  212.  
  213. ;PRINT "@X00@X4CAvailability of this PPE: Not Yet <grin>@XFF"
  214.  
  215. ANSIPOS 24,3
  216.  
  217. ' Get the filename(s) to download.
  218.  
  219. INPUTSTR "_", Files2DL, 07h, 55, MASK_FILE()+"*?", UPCASE + STACKED
  220.  
  221. ANSIPOS 1,22
  222.  
  223. ' Stuff the filename(s) to download into the keyboard buffer and let PCBoard
  224. ' deal with it.
  225.  
  226. KBDSTUFF Files2DL + chr(13)
  227.  
  228. ' Create a semaphor file.  This tells us when we just asked for input.
  229.  
  230. IF (LEN(LTRIM(Files2DL," ")) != 0) THEN
  231.    FCREATE 3, "DL"+STRING(PCBNODE())+".$$$", O_WR, S_DB
  232.    FCLOSE 3
  233. ENDIF
  234.  
  235. RETURN
  236.  
  237.  
  238. ;*****************************************************************************
  239. :DisplayRIP
  240.  
  241. ' See the DisplayANSI section for commenntary.  Hey, I'm no Andy Rooney.
  242.  
  243. GOSUB ReadLastFive
  244.  
  245. ANSIPOS 1,15
  246.  
  247. FOR Counter = 1 TO 5
  248.    PRINT ESC + "[4C"
  249.    PUSH Counter
  250.    GOSUB PrintEntry
  251. NEXT
  252.  
  253. GOSUB EstimateBatch
  254.  
  255. ANSIPOS 12,24
  256. OPTEXT FLAGCNT()
  257. PRINT "@X0F", "@OPTEXT:4R@"
  258.  
  259. PRINT ESC + "[17C"
  260. OPTEXT BatchSize
  261. PRINT "@X0F", "@OPTEXT:10@"
  262.  
  263. PUSH  BatchSeconds
  264. GOSUB Time2Text
  265.  
  266. PRINT ESC + "[19C"
  267. PRINT "@X0F", TimeText
  268.  
  269. ANSIPOS 24,3
  270.  
  271. INPUTSTR "_", Files2DL, 07h, 55, MASK_FILE()+"*?", UPCASE + STACKED
  272.  
  273. KBDSTUFF Files2DL + chr(13)
  274.  
  275. ANSIPOS 1,28
  276.  
  277. RETURN
  278.  
  279.  
  280. ;*****************************************************************************
  281. :Time2Text
  282.  
  283. ' This routine POPs the integer value (seconds) PUSHed onto the stack and
  284. ' turns it into a text string.  If 2852 is passed to this routine, it knows
  285. ' this value to be:
  286. '
  287. '       47 min 32 sec
  288. '
  289. ' A value of 4000, would return
  290. '
  291. '       1 hrs 7 mins
  292. '
  293. ' In other words, this routine is smart enough to determine if hours or
  294. ' minutes should be used in the display to make it more readable.
  295.  
  296. POP ReadSeconds
  297.  
  298. IF (ReadSeconds >= 3600) THEN
  299.    NumHours = TOINT(ReadSeconds / 3600)
  300.    TimeText = RIGHT(STRING(NumHours),2) + " hrs "
  301.    NumMin   = TOINT((ReadSeconds - (NumHours * 3600)) / 60)
  302.    TimeText = TimeText + STRING(RIGHT(NumMin,2)) + " min"
  303. ELSE
  304.    NumMin   = TOINT(ReadSeconds / 60)
  305.    TimeText = RIGHT(STRING(NumMin),2) + " min "
  306.    TimeText = TimeText + STRING(RIGHT((ReadSeconds - (NumMin * 60)),2)) + " sec"
  307. ENDIF
  308.  
  309. RETURN
  310.  
  311.  
  312. ;*****************************************************************************
  313. :EstimateBatch
  314.  
  315. ' Read the FLIST file to gather statistics for the entire batch.
  316.  
  317. FSEEK 2, 79, SEEK_CUR
  318. FOR Counter = 1 to FLAGCNT()
  319.    FREAD 2, ReadSize   , 4
  320.    FREAD 2, ReadSeconds, 4
  321.    FSEEK 2, RecSize-8, SEEK_CUR
  322.    BatchSeconds = BatchSeconds + ReadSeconds
  323.    BatchSize    = BatchSize    + ReadSize
  324. NEXT
  325. RETURN
  326.  
  327.  
  328. ;*****************************************************************************
  329.  
  330. :PrintEntry
  331.  
  332. ' Print a statistic line on the screen.  Rember, this handles up to five
  333. ' display lines.
  334.  
  335. POP LineNo
  336.  
  337. IF (MoreThanFiveFiles) THEN
  338.   OPTEXT (FLAGCNT()-5) + LineNo
  339. ELSE
  340.   OPTEXT LineNo
  341. ENDIF
  342.  
  343. PRINT "@X0B@OPTEXT:4R@"
  344. FORWARD 3
  345.  
  346. OPTEXT Filename(LineNo)
  347. PRINT "@X0F@OPTEXT:15@"
  348.  
  349. OPTEXT Size(LineNo)
  350. PRINT "@X0F@OPTEXT:10R@"
  351. FORWARD 4
  352.  
  353. PUSH Seconds(LineNo)
  354. GOSUB Time2Text
  355. OPTEXT TimeText
  356. PRINT "@OPTEXT@"
  357.  
  358. PRINT "@POS:61@"
  359.  
  360. IF (Free(LineNo)) THEN
  361.    PRINT "@X0A■"
  362. ELSE
  363.    PRINT "@X08·"
  364. ENDIF
  365.  
  366. PRINT "@POS:71@"
  367.  
  368. IF (NoTime(LineNo)) THEN
  369.    PRINT "@X0A■"
  370. ELSE
  371.    PRINT "@X08·"
  372. ENDIF
  373.  
  374. PRINTLN
  375.  
  376. RETURN
  377.  
  378.  
  379. ;*****************************************************************************
  380.  
  381. :ReadLastFive
  382.  
  383.    IF (FLAGCNT() <= 5) THEN
  384.       MoreThanFiveFiles = FALSE
  385.       GOSUB GetLineInfo
  386.    ELSE
  387.       FSEEK 1, -(5 * RecSize), SEEK_END
  388.       MoreThanFiveFiles = TRUE
  389.       GOSUB GetLineInfo
  390.    ENDIF
  391. RETURN
  392.  
  393.  
  394. ;*****************************************************************************
  395.  
  396. :GetLineInfo
  397.  
  398. IF (MoreThanFiveFiles) THEN
  399.    EndCounter = 5
  400. ELSE
  401.    EndCounter = FLAGCNT()
  402. ENDIF
  403.  
  404. FOR Counter = 1 TO EndCounter
  405.    FSEEK 1, 66, SEEK_CUR
  406.    FREAD 1, Filename(Counter), 13
  407.    FREAD 1, Size(Counter), 4
  408.    FREAD 1, Seconds(Counter), 4
  409.    FSEEK 1, 8, SEEK_CUR
  410.    FREAD 1, Free(Counter), 1
  411.    FREAD 1, NoTime(Counter), 1
  412.    FSEEK 1, RecSize - 97, SEEK_CUR
  413. NEXT
  414. RETURN
  415.