Function RandomLine(FileName : String ; Lines : integer) : String; var StrL : TStringList; i : integer; Tmpr : Real; begin Result := ''; if (Not Fileexists(FileName)) or (Lines<1) then exit; StrL := TStringList.Create; StrL.LoadFromFile(FileName); Tmpr := Int(random*(Strl.Count-Lines)); if Tmpr<0 then Tmpr := 0; for i:= StrToInt(FloatToStr(Tmpr)) to StrToInt(FloatToStr(Tmpr))+Lines do Result := Result + StrL.Strings[i] + #13#10; Strl.Free; end;
var
StrL : TStringList;
i : integer;
Tmpr : Real;
begin
Result := '';
if (Not Fileexists(FileName)) or (Lines<1) then exit;
StrL := TStringList.Create;
StrL.LoadFromFile(FileName);
Tmpr := Int(random*(Strl.Count-Lines));
if Tmpr<0 then Tmpr := 0;
for i:= StrToInt(FloatToStr(Tmpr)) to StrToInt(FloatToStr(Tmpr))+Lines do
Result := Result + StrL.Strings[i] + #13#10;
Strl.Free;
end;