home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / PRT_QUEU.ZIP / QTEST.PAS next >
Encoding:
Pascal/Delphi Source File  |  1988-10-26  |  3.0 KB  |  141 lines

  1. program qtest;
  2. {  nothing special, just a quickie for testing the functions in
  3. "QUEUEMAN.TPU" }
  4. uses
  5.     crt, QueueMan;
  6.  
  7. type
  8.     qEntry = array[1..64] of char;
  9.     qptr = ^qEntry;
  10.  
  11. procedure QerrMsg( errnum : word);
  12. { prints a message based on the error number }
  13. begin
  14.     case errnum of
  15.         2 : writeln( 'File Not Found.');
  16.         3 : writeln( 'Path Not Found.');
  17.         4 : writeln( 'Too Many Open Files. (Increase FILES= in config.sys)');
  18.         5 : writeln( 'Access Denied.');
  19.         8 : writeln( 'Queue Full.');
  20.         9 : writeln( 'Busy.');
  21.         12 : writeln( 'Name Too Long.');
  22.         15 : writeln( 'Invalid Drive.');
  23.         else
  24.             writeln( 'Unknown Error!');
  25.     end; {case}
  26. end;
  27.  
  28.  
  29. procedure ShowList;
  30. var
  31.     qpoint : qptr;
  32.     index : integer;
  33. begin
  34.     writeln;
  35.     qpoint := QueuePointer;        { get print.com's list address }
  36.     if qpoint^[1] = #0 then
  37.         writeln( 'There are no files currently in the queue.')
  38.     ELSE
  39.     begin
  40.         writeln( 'Current queue contents:');
  41.         repeat
  42.             index := 1;
  43.             while qpoint^[index] <> #0 do
  44.             begin                                { write characters up to the terminator }
  45.                 write( qpoint^[index]);
  46.                 inc( index);
  47.             end;
  48.             writeln;
  49.             qpoint := ptr( seg(qpoint^), ofs(qpoint^)+64);    { move pointer to next }
  50.         until qpoint^[1] = #0;
  51.     end;
  52. end;
  53.  
  54. procedure PrintFile;
  55. var
  56.     SubFile : string;
  57.     tmperror : word;
  58. begin
  59.     writeln;
  60.     write( 'Enter the name of the file to be printed ->');
  61.     readln( SubFile);
  62.     tmperror := SubmitFile( SubFile);
  63.     if tmperror <> 0 then
  64.         QerrMsg( tmperror)
  65.     ELSE
  66.             writeln( 'File successfully queued.');
  67.     writeln;
  68. end;
  69.  
  70. procedure FileCancel;
  71. var
  72.     CanFile : string;
  73.     tmperror : word;
  74. begin
  75.     writeln;
  76.     write( 'Enter the name of the file to be cancelled->');
  77.     readln( CanFile);
  78.     tmperror := CancelFile( CanFile);
  79.     if tmperror <> 0 then
  80.         QerrMsg( tmperror)
  81.     ELSE
  82.         writeln( 'File cancelled.');
  83.     writeln;
  84. end;
  85.  
  86. procedure AllCancel;
  87. var
  88.     tmperror : word;
  89. begin
  90.     writeln;
  91.     writeln( 'Cancelling files. One moment, please.');
  92.     tmperror := KillQueue;
  93.     if tmperror <> 0 then
  94.         QerrMsg( tmperror)
  95.     ELSE
  96.         writeln( 'All files cancelled.');
  97.     writeln;
  98. end;
  99.  
  100. var
  101.     tmpchar : char;
  102.     exitmain : boolean;
  103. begin
  104.     if QueueInstalled then
  105.     begin
  106.         exitmain := FALSE;
  107.         repeat
  108.             writeln( '--- Qtest menu ---');
  109.             writeln( '1) Show queue list');
  110.             writeln( '2) Submit file to queue');
  111.             writeln( '3) Cancel a file');
  112.             writeln( '4) Cancel ALL files');
  113.             writeln( '5) Pause printing');
  114.             writeln( '6) Continue printing after pause');
  115.             writeln( '7) Exit to DOS');
  116.             tmpchar := ReadKey;
  117.             case tmpchar of
  118.                 '1' : ShowList;
  119.                 '2' : PrintFile;
  120.                 '3' : FileCancel;
  121.                 '4' : AllCancel;
  122.                 '5' : begin
  123.                             writeln;
  124.                             PauseQueue;
  125.                             writeln( 'Printing is paused.');
  126.                             writeln;
  127.                         end;
  128.                 '6' : begin
  129.                             writeln;
  130.                             ContinueQueue;
  131.                             writeln( 'Printing is restarted.');
  132.                             writeln;
  133.                         end;
  134.                 '7' : exitmain := TRUE;
  135.            end; {case}
  136.             writeln;
  137.         until exitmain = TRUE;
  138.     end
  139.     ELSE
  140.         writeln( 'ERROR! Print.com not installed. Aborting.');
  141. end.