
22.07.2009, 13:42
|
Активный
|
|
Регистрация: 29.03.2009
Сообщения: 300
Репутация: 94
|
|
Код:
const
COMPNAME = 'comp5'; // например
FILEPATH = 'comps.txt'; // например
var
comps: TStringList;
i: Integer;
Str: string;
begin
comps := TStringList.Create;
try
if not FileExists(FILEPATH) then Exit;
comps.LoadFromFile(FILEPATH);
Str := Copy(comps.Text, 1, Pos(#13#10, comps.Text) + 2);
if (Pos(' ' + COMPNAME + ' ', str) = 0) and
(Pos(' ' + COMPNAME + #13, str) = 0) then
begin
for i := 0 to comps.Count - 1 do
comps.Strings[i] := comps.Strings[i] + ' ' + COMPNAME;
comps.SaveToFile(FILEPATH);
end;
finally
comps.Free;
end;
end;
|