{***********************************************************************}
{									}
{ __WrtPrt    Send a string to the printer via the BIOS 		}
{									}
{ procedure __InitPrt(	     PortNo : byte;				}
{				Str : string;				}
{		      var NoWritten : byte;				}
{			 var Status : byte);				}
{									}
{	      PortNo	The printer port number. 0 = lpt1, 1 = lpt2 and }
{			2 = lpt3 are the only valid values.  No action	}
{			is taken if a different value is specified.	}
{	      Str	The string of characters to send to the printer }
{			port.						}
{	      NoWritten The number of characters of the string trans-	}
{			mitted to the printer.	If NoWritten is less	}
{			than the length of the string, the condition(s) }
{			preventing full transmission are reported in	}
{			the returned status byte.			}
{	      Status	The returned status.  The value may be a com-	}
{			bination of the following:			}
{									}
{			($01) _TIMEOUT_PRT				}
{			($08) _IOERROR_PRT				}
{			($10) _ONLINE_PRT				}
{			($20) _NOPAPER_PRT				}
{			($40) _ACK_PRT					}
{			($80) _NOTBUSY_PRT				}
{									}
{			The values are added together to specify more	}
{			than one event. 				}
{									}
{ Description This procedure uses __BytePrt to transmit an entire	}
{	      string to the printer port.  The number of characters	}
{	      actually transmitted is returned in NoWritten.		}
{									}
{	      If an invalid port number is specified (only 0 through 2	}
{	      are allowed), or if there is no physical printer port	}
{	      associated, no action is taken.  In the former case, the	}
{	      Status byte is not altered.				}
{									}
{ Version     4.00 (C)Copyright Blaise Computing Inc.  1987		}
{_______________________________________________________________________}

procedure __WrtPrt(	  PortNo : byte;
			     Str : string;
		   var NoWritten : byte;
		      var Status : byte);

  var
    LenStr,I	: byte;
    ErrorStatus : byte;

  begin {__WrtPrt}

    NoWritten := 0;
    if (PortNo > 2) then
       Exit;			       { Invalid port number		}

    { First make sure the printer is available.  Check that it is on-	}
    { line and not out of paper.					}

     __StatPrt(PortNo,Status);
     if ( ((Status and _ONLINE_PRT) = 0) or
				  ((Status and _NOPAPER_PRT) <> 0) ) then
	 Exit;

    ErrorStatus := _TIMEOUT_PRT + _IOERROR_PRT + _NOPAPER_PRT;
    LenStr	:= Length(Str);

    for I := 1 to LenStr do
      begin

	{ Wait for the printer to be ready accept more data.  If an	}
	{ error is encountered, exit immediately returning the status.	}

	repeat
	  __StatPrt(PortNo,Status);
	  if ((Status and ErrorStatus) <> 0) then
	     Exit
	until ((Status and _NOTBUSY_PRT) <> 0);

	__BytePrt(PortNo,byte(Str[I]),Status);
	if ((Status and ErrorStatus) <> 0) then
	   Exit
	else
	   Inc(NoWritten)

      end;

  end;	{__WrtPrt}
