Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (*
- Author: R. J. Cano.
- Written on Sat Dec 29 2012, 02:09 VET.
- THIS PROGRAM IS FREE SOFTWARE AND GOES WITHOUT ANY WARRANTY WHATSOEVER.
- RELEASED UNDER THE TERMS OF THE GNU GPLv3.0 LICENSE.
- For details please see: http://www.gnu.org/licenses/gpl-3.0.txt
- *)
- program plainTextGardener;
- const
- TAB=#9;
- WhiteSpace=#32;
- delim=':';
- definedFields=4;
- fieldSize_offsets=6;
- fieldSize_data=16;
- interFieldSize=3;
- fieldBound=2*(fieldSize_offsets+fieldSize_data)+(definedFields-1)*interFieldSize;
- fieldSize : array [1..definedFields] of byte= (fieldSize_offsets, fieldSize_data, fieldSize_data, fieldSize_offsets);
- var
- f: text;
- s: string;
- i,j,k,l,t: byte;
- begin
- assign(f, paramstr(1));
- reset(f);
- while (not eof(f)) do begin
- readln(f,s);
- for t:= 1 to length(s) do begin (*Ignores the TABS*)
- if (s[t]=TAB) then s[t]:= WhiteSpace;
- end;
- i:= 1; (* Current field *)
- if (length(s) < fieldBound) then begin
- j:=0; (* How many chars before delim *)
- k:=0; (* Cursor *)
- while ( (i <= definedFields) and (k<length(s)) ) do begin
- k:= k + 1;
- if ((s[k]=delim)) then begin
- (* Also: It would work properly to subtract "j" directly from fieldBound *)
- for l:= 1 to (fieldSize[i]-j) do write(' ');
- for l:= 1 to interFieldSize do write(' ');
- i:= i + 1;
- j:=0;
- end else begin
- write(s[k]);
- j:= j + 1;
- end;
- end;
- writeln();
- end else begin
- writeln(s);
- end;
- end;
- close(f);
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement