{***********************************************************************}
{									}
{ __SpCanPrt  Cancel files in the DOS print spooler queue		}
{									}
{ procedure __SpCanPrt(PathName : _Path; var ErrorCode : word); 	}
{									}
{	      PathName	The full path name of the file to be printed.	}
{			The file name may the contain global character	}
{			(?). If the PathName is the null string, all	}
{			queued files are cancelled.			}
{	      ErrorCode The returned error status code. 		}
{			0 - Filenames successfully cancelled		}
{			1 - Spooler not installed. You must execute	}
{			    the PRINT command.				}
{			9 - Spooler is busy; unable to get attention.	}
{									}
{ Description This procedure removes a file or files from the DOS	}
{	      spooler.	__SpCanPrt behaves like the /C option of the	}
{	      DOS PRINT command, with the exception that specifying	}
{	      a null path removes all files from the queue (that is,	}
{	      it behaves like the /T option).				}
{									}
{ Version     4.00 (C)Copyright Blaise Computing Inc. 1987		}
{_______________________________________________________________________}

procedure __SpCanPrt(PathName : _Path; var ErrorCode : word);

  var
    PathZ     : _Path;
    PathLen   : integer;
    CancelAll : boolean;
    Reg       : registers;

  begin {SpCanPrt}

    if (not __SpInsPrt) then
       begin
	 ErrorCode := _NOTINSTALLED_PRT;
	 Exit
       end;

    PathLen := Length(PathName);
    if (PathLen = 0) then
       CancelAll := TRUE
    else
       begin
	 CancelAll := FALSE;
	 Move(PathName[1],PathZ,PathLen);
	 PathZ[PathLen] := #0
       end;

    with Reg do
      begin
	if (CancelAll) then
	   AX := $0103		       { Cancel all files		}
	else
	   begin
	     AX := $0102;	       { Cancel specified file		}
	     DS := Seg(PathZ);	       { DS:DX points to the ASCIIZ	}
	     DX := Ofs(PathZ);	       { path name.			}
	   end;
	Intr(_PRINT,Reg);
	if ((Flags and FCarry) <> 0) then { Carry flag is set; an error }
	   ErrorCode := AX	       { occurred and number is in AX	}
	else
	   ErrorCode := 0	       { Successful submission		}
      end

  end;	{__SpCanPrt}
