Uses Lsystems,Graph;

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

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;

 WriteLn('Enter stage number');
 ReadLn(Turn);

 fname := calculate(Frac,Turn);
 turn:=0;
 r:=0;
 InitGraph(r,turn,'');
   DrawLsys(Fname,frac);
   ReadLn;
 CloseGraph;
 DestroyLsys(Frac);
end.