Uses Lsystems,Graph;

var
 Inp : TEXT;
 Ax,Comm,Fname : string;
 Frac : PLSYS;
 Rule : string;
 Turn,r  : integer;

Label P1,P2;

begin
  If ParamCount <> 1 then Assign(Inp,'input.fra')
  else Assign(inp,ParamStr(1));
  {$I-}
   Reset(Inp);
  {$I+}
  If IOResult <> 0 then
   begin
     WriteLn('File open Error');
     HAlt(220);
   end;
 ReadLn(inp,comm);
 repeat
  readln(inp,ax);
 until comm[1] = ';';
 Val(Ax,Turn,R);
 ReadLn(Inp,Ax);
 Frac := CreateLsys(Ax,copy(Comm,2,Length(Comm)-1),Turn);

 while not EOF(inp) do begin
   ReadLn(inp,rule);
   if Length(Rule) > 2 then AddRule(Frac,rule[1],copy(rule,3,Length(rule)-2));
 end;

 turn:=0;
 r:=0;
 InitGraph(r,turn,'');
 fname := calculate(Frac,0);
P1:
   asm
     mov ah, 01
     int 16h
     jnz P2
   end;
   ClearDevice;
   DrawLsys(Fname,frac);
   fname := Advance(Frac,Fname);
   goto p1;
P2:

 ReadLn;
 CloseGraph;
 DestroyLsys(Frac);
end.