home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / RFORM.ZIP / _SFORM.IMP < prev    next >
Encoding:
Text File  |  1988-01-06  |  999 b   |  38 lines

  1. function FormStr(Picture : string;
  2.                  S       : string) : string;
  3.  
  4.   const StrFieldSet : set of char = ['#','@'];
  5.  
  6.   var FieldStr  : string;
  7.       Position,
  8.       I,K       : word;
  9.  
  10.   begin
  11.     Position:=1;     {Ignore stand alone '.' and ','}
  12.     while ((not (Picture[Position] in StrFieldSet))
  13.       and (Position <= length(Picture))) do
  14.         inc(Position);
  15.     if (Position > length(Picture)) then
  16.       begin
  17.         Position:=0;
  18.         FieldStr:='';
  19.       end
  20.     else
  21.       begin
  22.         I:=Position;
  23.         while (Picture[I] in StrFieldSet)
  24.           and (I<=length(Picture)) do
  25.             inc(I);
  26.         FieldStr:= copy(Picture,Position,I-Position);
  27.       end;
  28.     if (pos('@',FieldStr)<>0) then
  29.       while (length(S) < length(FieldStr)) do
  30.         S:=' '+S
  31.     else
  32.       while (length(S) < length(FieldStr)) do
  33.         S:=S+' ';
  34.     for I:=1 to length(FieldStr) do
  35.       Picture[Position+I-1]:=S[I];
  36.     FormStr:=Picture;
  37.   end;
  38.