summaryrefslogtreecommitdiff
path: root/graphics/mf2tex/log2tex.pas
blob: 5cdcbcbf383a17e0da0e4de4f77960238cbcae25 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
{convertor from generated LOG files to the corresponding TeX sources

 this program is for dos-systems}
 
program log2tex;
uses
	dos;
var
	fi,fo:text;
	line:string;
	d:dirstr;
	n:namestr;
	e:extstr;

procedure
	error(txt:string);
begin
	writeln(txt);
	halt(1);
end;

begin
	if paramcount>=1 then begin
		line:=paramstr(1);
	end else begin
		write('input: ');
		readln(line);
	end;
	fsplit(line,d,n,e);
	if e='' then line:=line+'.log';
	assign(fi,line);
	{$i-} reset(fi); {$i+}
	if ioresult<>0 then
		error('can not open input file');
	while not eof(fi) do begin
		readln(fi,line);
		if copy(line,1,4)='$#@!' then begin
			line:=copy(line,5,255);
			assign(fo,line+'.tex');
			{$i-} rewrite(fo); {$i+}
			if ioresult<>0 then
				error('can not open output file');
			break;
		end;
	end;
	while not eof(fi) do begin
		readln(fi,line);
		if copy(line,1,4)='!@#$' then
			writeln(fo,copy(line,5,255));
	end;
	close(fo);
	close(fi);
end.