home *** CD-ROM | disk | FTP | other *** search
/ Boston 2 / boston-2.iso / DOS / PROGRAM / BASIC / POWBASIC / LIBRARY2 / SPOOL.ZIP / DOSPOOL.BAS < prev   
BASIC Source File  |  1990-07-09  |  4KB  |  158 lines

  1. $link "dospool.obj"
  2.  
  3. ' ----------------------------------------------------------------------------
  4.  
  5. declare function spool%(integer,string)
  6.  
  7. ' integer = 0 - Status check
  8. '        1 - Submit file
  9. '        2 - Remove file
  10. '        3 - Cancel all files
  11. '        4 - hold printing
  12. '        5 - resume printing
  13.  
  14. ' string  = if integer is 0,3,4,5 - null string
  15. '         = if integer is 1 - packet
  16. '         = if integer is 2 - asciiz file name
  17. ' ----------------------------------------------------------------------------
  18. ' Demonstration of STATUS
  19.  
  20. cls
  21.  
  22. a% = spool%(0," ")
  23.  
  24. select case a%
  25.   case = 0
  26.     print "PRINT not installed.  Installing....."
  27.  
  28. '***
  29. ' In order for this to work, PRINT must be in a directory included in
  30. ' your path, or in the current directory.
  31. '***
  32.  
  33.     shell "PRINT /D:PRN > NUL:"
  34.     a% = 255
  35.   case = 1
  36.     print "PRINT not installed.  NOT Ok to install."
  37.   case = 255
  38.     print "PRINT installed."
  39.   case else
  40.     print "Unknown Status."
  41. end select
  42.  
  43. ' ----------------------------------------------------------------------------
  44. ' Demonstration of SUBMIT
  45.  
  46. if a% = 255 then
  47.   print
  48.   input "Enter file to spool : ";filname$
  49.   if filname$ <> null$ then
  50.  
  51. ' ***
  52. '   The following two lines build the packet as required by PRINT
  53. ' ***
  54.  
  55.     filname$ = ucase$(filname$) + chr$(0)
  56.     packet$ = chr$(0) + mki$(strptr(filname$)) + mki$(strseg(filname$))
  57.  
  58.     a% = spool%(1,packet$)
  59.     print "Result of Submit is: ";a%;" - ";
  60.     select case a%
  61.       case = 0
  62.     print "No Error."
  63.       case = 1
  64.     print "Function Invalid."
  65.       case = 2
  66.     print "File not found."
  67.       case = 3
  68.     print "Path not found."
  69.       case = 4
  70.     print "Too many open files."
  71.       case = 5
  72.     print "Access denied."
  73.       case = 8
  74.     print "Queue full."
  75.       case = 9
  76.     print "Spooler busy."
  77.       case = 12
  78.     print "Name too long."
  79.       case = 15
  80.     print "Drive invalid."
  81.       case else
  82.     print "Unknown error."
  83.     end select
  84.   end if
  85. end if
  86.  
  87. ' ----------------------------------------------------------------------------
  88. ' Demonstration of REMOVE
  89.  
  90. print
  91. input "Enter a filename to remove from the queue {return = none}: ";xfile$
  92. if xfile$ <> null$ then
  93.  
  94. '***
  95. ' Make sure the filename ends with a chr$(0) !
  96. '***
  97.  
  98.   xfile$ = ucase$(xfile$) + chr$(0)
  99.  
  100.   a% = spool%(2,xfile$)
  101.   print "Result of Remove: ";a%;" - ";
  102.   select case a%
  103.     case = 0
  104.       print "No Error."
  105.     case = 1
  106.       print "Function Invalid."
  107.     case = 2
  108.       print "File not found."
  109.     case = 3
  110.       print "Path not found."
  111.     case = 4
  112.       print "Too many open files."
  113.     case = 5
  114.       print "Access denied."
  115.     case = 8
  116.       print "Queue full."
  117.     case = 9
  118.       print "Spooler busy."
  119.     case = 12
  120.       print "Name too long."
  121.     case = 15
  122.       print "Drive invalid."
  123.     case else
  124.       print "Unknown error."
  125.     end select
  126. end if
  127.  
  128. ' ----------------------------------------------------------------------------
  129. ' Demonstration of CANCEL
  130.  
  131. print
  132. input "Do you want to cancel all the files in the spooler? {Y/N}: ";can$
  133. if ucase$(can$) = "Y" then
  134.   a% = spool%(3," ")
  135.   print
  136.   print "Result of Cancel: ";a%
  137. end if
  138.  
  139. ' ----------------------------------------------------------------------------
  140. ' Demonstration of HOLD
  141.  
  142. print
  143. print "Holding Print ......  Press any key to resume."
  144.  
  145. a% = spool%(4," ")
  146.  
  147. while inkey$ = null$ : wend
  148.  
  149. ' ----------------------------------------------------------------------------
  150. ' Demonstration of RESUME
  151.  
  152. b% = spool%(5," ")
  153. print
  154. print "Result of Hold:   ";a%
  155. print "Result of Resume: ";b%
  156.  
  157. stop
  158.