{***********************************************************************}
{									}
{ __FillStr   Fill a string with copies of a character. 		}
{									}
{ function  __FillStr(FillCh : char; Target : string;			}
{				  ChPos,Num : word) : string;		}
{									}
{	      FillCh	The character to place in the target string.	}
{	      Target	The string in which the copies of the fill	}
{			character are placed.				}
{	      ChPos	The character position within Target at which	}
{			copies of the fill character are placed.	}
{	      Num	The number of copies of FillCh to write.	}
{									}
{ Description This function returns a string with Num copies of the	}
{	      character FillCh written	at character position ChPos.	}
{	      The original string Target is not altered.  If ChPos is	}
{	      less than 1, copies of the character are placed starting	}
{	      at position 1 of Target, and if ChPos is greater than	}
{	      the length of Target, the characters are concatenated to	}
{	      Target.  If the resulting string has a length greater	}
{	      than the maximum string length (MAXSTR_), the left	}
{	      most MAXSTR_  characters are returned. Notice that,	}
{	      unlike __MidStr, __FillStr does not insert characters,	}
{	      but rather overwrites characters. 			}
{									}
{ Version     4.00 (C)Copyright Blaise Computing Inc.  1987		}
{_______________________________________________________________________}

function  __FillStr(FillCh : char; Target : string;
				ChPos,Num : word) : string;

  var
    LenTarget : word;
    StartPos  : word;

  begin {__FillStr}

    if (Num <= 0) then		       { Leave immediately if there is	}
       Exit;			       { nothing to do. 		}

    LenTarget := Length(Target);       { Determine reasonable values	}
    if (ChPos < 1) then 	       { the starting position and num- }
       StartPos := 1		       { ber of characters to write.	}
    else if (ChPos > LenTarget) then
       StartPos := LenTarget + 1
    else
       StartPos := ChPos;
    if (Num > (MAXSTR_ - StartPos + 1)) then
       Num := MAXSTR_ - StartPos + 1;

    FillChar(Target[StartPos],Num,FillCh);

    if (LenTarget < (StartPos + Num)) then
       Length(Target) := StartPos + Num - 1;

    __FillStr := Target

  end;	{__FillStr}
