home *** CD-ROM | disk | FTP | other *** search
/ Boston 2 / boston-2.iso / DOS / PROGRAM / BASIC / POWBASIC / LIBRARY4 / SPOOLK.ZIP / SPKDEMO.BAS next >
BASIC Source File  |  1990-11-23  |  5KB  |  180 lines

  1. $COMPILE EXE
  2. $LIB ALL OFF
  3. DEFINT a-z
  4. $INCLUDE "SPOOLKIT.INC"
  5. $LINK "SPOOLKIT.PBU"
  6.  
  7. DIM STATIC QueList$(32)
  8. CLS
  9. locate 4,1
  10. print TAB(28);" SpoolKit version 1.0 demo"
  11. print " "
  12. print "Testing for presence of DOS PRINT resident - ";
  13. IF SpoolInstalled% THEN
  14.      PRINT "found it, SPKDEMO ready to go!"
  15. ELSE
  16.      PRINT "spooler not installed, can't run demo"
  17.      end
  18. END IF
  19.  
  20. print "Press any key to begin the demo, or ESC to stop"
  21. CALL WaitForKey
  22. ' Part 1
  23. print " "
  24. print " "
  25. print "Part 1:  Checking current contents of spool queue"
  26. print "This test simply lists the contents of the print spooler job queue"
  27. print " "
  28. CALL ListSpooledFiles(QueList$(),Count%,Stat%)
  29. IF Stat% <> 0 THEN
  30.     print tab(10);"* Error number ";Stat%;" occurred, demo stopping"
  31.     STOP
  32. END IF
  33. print TAB(10);" - Number of queued files: ";Count%
  34. IF Count% > 0 THEN
  35.     FOR x% = 1 to Count%
  36.         print TAB(15);QueList$(x%)
  37.     NEXT x%
  38. END IF
  39.  
  40. Print " "
  41. Print "Press any key for next step, ESC to stop demo"
  42. Call WaitForKey
  43.  
  44. ' Part 2
  45.  
  46. CLS
  47. LOCATE 4,1
  48. print "Part 2:  Submit a file to print"
  49. print " "
  50. print "This test will submit a print file to the spooler.  When asked for a"
  51. print "file name, give the path of a single file.  For demonstration purpose,"
  52. print "a short file will work as good as a long one (i.e. C:\CONFIG.SYS)."
  53. print "If your printer is on-line and ready, the file should print."
  54. print " "
  55. Input "Enter name of file to print: ";a$
  56. CALL SubmitSpoolFile(a$,Count%,Stat%)
  57. SELECT CASE Stat%
  58.    CASE 0
  59.       print tab(10);Count%;" files successfully spooled"
  60.    CASE 8
  61.       print Tab(10);"Print spooler queue is full,";Count%;" files spooled"
  62.    CASE ELSE
  63.       print Tab(10);"Error number";Stat%;" occurred, demo stopping"
  64.       STOP
  65. END SELECT
  66.  
  67. Print " "
  68. Print "Press any key for next step, ESC to stop demo"
  69. Call WaitForKey
  70. CLS
  71. locate 4,1
  72. print "Part 3:  Cancel a file from print queue"
  73. print " "
  74. print "This portion of the demo will queue several files to the spooler, then"
  75. print "ask you which one to remove from the spool queue.  You will be asked to"
  76. print "take your printer off-line first, so that the files will not finish"
  77. print "printing while you are typeing your answers.  This is an advantage to"
  78. print "using the DOS PRINT spooler.  The PowerBasic programmer is relieved"
  79. print "from having to deal with the printer being offline, out of paper, etc"
  80. print " "
  81. print "Please take your printer off-line, press any key when done (ESC exits)"
  82. CALL WaitForKey
  83. print " "
  84. print "I now need you to supply a wild card file specification.  All files"
  85. print "meeting the specification will be placed in the spool queue.  Please"
  86. print "use a file spec that will cause more than one file to enter the queue"
  87. print "The demo will stop submitting files if the spooler queue fills up.
  88. print " "
  89. print "An example would be: C:\BIN\*.BAT"
  90. print " "
  91. line input "Please enter a file specification: ";x$
  92. print " "
  93. print "Queueing files . . .";
  94. CALL SubmitSpoolFile(x$,Count%,Stat%)
  95. SELECT CASE Stat%
  96.    CASE 0
  97.       print tab(10);Count%;" files successfully spooled"
  98.    CASE 8
  99.       print Tab(10);"Print spooler queue is full,";Count%;" files spooled"
  100.    CASE ELSE
  101.       print Tab(10);"Error number";Stat%;" occurred while submitting, demo stopping"
  102.       STOP
  103. END SELECT
  104. CALL ListSpooledFiles(QueList$(),Count%,Stat%)
  105. IF Stat% <> 0 THEN
  106.     print "     * Error number ";Stat%;" occurred listing queue, can't continue"
  107.     STOP
  108. END IF
  109. print "Press any key for a list of the contents of the PRINT queue (ESC quits)"
  110. CALL WaitForKey
  111. CLS
  112. locate 4,1
  113. print "List of";Count%;" queued files: "
  114. IF Count% > 0 THEN
  115.     FOR x% = 1 to Count%
  116.         print "    ";QueList$(x%)
  117.     NEXT x%
  118. END IF
  119.  
  120. print " "
  121. print "We will now remove files from the queue.  Enter the FULLY QUALIFIED"
  122. print "path and file name of the file or files to be removed for the queue"
  123. print "Wild cards are OK, but must include a drive/path specification"
  124. print " "
  125. line input "Please enter FULL specification of file to cancel: ";x$
  126. CALL RemoveFromSpool(x$,Stat%)
  127. SELECT CASE Stat%
  128.     Case 0
  129.       PRINT "Files successfully removed from queue"
  130.         CALL ListSpooledFiles(QueList$(),Count%,Stat%)
  131.         print "Press any key for new list of queued files. (ESC quits) "
  132.       CALL WaitForKey
  133.       print "PRINT queue contains";Count%;" files"
  134.         IF Count% > 0 THEN
  135.             FOR x% = 1 to Count%
  136.                 print "    * ";QueList$(x%)
  137.             NEXT x%
  138.         END IF
  139.     CASE 2,3,&H0C
  140.         PRINT "    * INVALID name given"
  141.     CASE ELSE
  142.         PRINT "    * Error number ";Stat%;" occurred removeing file, demo stopping"
  143.         STOP
  144. END SELECT
  145. Print " "
  146. Print "Press any key for next step, ESC to stop demo"
  147. Call WaitForKey
  148.  
  149. CLS
  150. print " "
  151. print "Part 4: Cancel all jobs in print queue"
  152. print "This last portion will remove all remaining jobs from the spooler queue."
  153. print "Press any key to remove all files.  (ESC Quits)"
  154. CALL WaitForKey
  155. print "Clearing PRINT queue."
  156. CALL CancelAllSpool(Stat%)
  157. CALL ListSpooledFiles(QueList$(),Count%,Stat%)
  158. print "List of queued files: "
  159. IF Count% > 0 THEN
  160.     FOR x% = 1 to Count%
  161.         print "    * ";QueList$(x%)
  162.     NEXT x%
  163. ELSE
  164.    print "    NONE!"
  165. END IF
  166.  
  167. print TAB(10);"GoodBye from the SPOOLKIT demo!"
  168.  
  169. end
  170.  
  171. SUB WaitForKey
  172. WHILE NOT INSTAT:WEND
  173. a$ = inkey$
  174. IF a$ = CHR$(27) THEN
  175.    locate 24,1
  176.    print "Demo stopped at user request"
  177.    STOP
  178. END IF
  179. END SUB
  180.