{***********************************************************************}
{									}
{ __SpSubPrt  Submit a file to the DOS print spooler			}
{									}
{ procedure __SpSubPrt(PathName : _Path; var ErrorCode : word); 	}
{									}
{	      PathName	The full path name of the file to be printed.	}
{			The file name may not contain global (wild	}
{			card) characters.				}
{	      ErrorCode The returned error status code.  The values are:}
{			0 - Successfully submitted to the spooler	}
{			1 - Spooler not installed. You must execute	}
{			    the PRINT command.				}
{			2 - File not found				}
{			3 - Path not found				}
{			4 - Too many files already open (not enough	}
{			    file handles available).			}
{			5 - Access denied (cannot submit files that	}
{			    cannot be "typed", e.g., directories,	}
{			    volume labels, etc.)			}
{			8 - The print spooler queue is full		}
{			9 - Spooler is busy; unable to get attention.	}
{									}
{ Description This procedure submits a file to the DOS print spooler	}
{	      for printing.  The effect of this procedure call is	}
{	      the same as issuing the command				}
{									}
{			PRINT pathname					}
{									}
{	      in response to the DOS prompt.  Unlike to DOS command,	}
{	      however, global filename characters are not allowed in	}
{	      the path name.						}
{									}
{ Version     4.00 (C)Copyright Blaise Computing Inc. 1987		}
{_______________________________________________________________________}

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

  type
    Submit = record
	       PrintLevel : byte;
	       PathPtr	  : _BytePtr
	     end;

  var
    SubmitBlock : Submit;
    PathZ	: _Path;
    PathLen	: integer;
    Reg 	: registers;

  begin {SpSubPrt}

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

    PathLen	   := Length(PathName);
    Move(PathName[1],PathZ,PathLen);
    PathZ[PathLen] := #0;
    with SubmitBlock do
      begin
	PrintLevel := 0;
	PathPtr    := Ptr(Seg(PathZ),Ofs(PathZ))
      end;

    with Reg do
      begin
	AX := $0101;		       { Submit a file for spooling	}
	DS := Seg(SubmitBlock);        { DS:DX points to the submit	}
	DX := Ofs(SubmitBlock);        { record structure		}
	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;	{__SpSubPrt}
