Delete Duplicates in the document

Ask questions about how to create a script or swap scripts with other users.
Post Reply
Aleks842
Posts: 13
Joined: 02 Apr 2014 16:37

Delete Duplicates in the document

Post by Aleks842 »

Can you help me. I try to use property TDuplicates of the component TStringList, but I get error "Undeclared identifier: Duplicates".

Code: Select all

// Pascal script
// Извлечение из текста ссылок
var
  i,j: integer;
  list:TStrings;
  st:string;
begin
   i := ScriptUtils.PosFrom('http://', Document.Text, 0);
  list:= TStringList.Create;
while i <> 0 do
      begin
      j := i + 7;
      while not (Document.Text[j] in ['/', ' ', '''', '"', '>']) do inc(j); //тут перечисляем признаки конца домена
            st := copy(Document.Text, i, j - i);
            list.Add(st); //куда-нибудь добавляем
            i := ScriptUtils.PosFrom('http://', Document.Text, i + 1);
      end;
      MainApp.NewDocument('');
      [color=#FF0000]list.Duplicates := dupIgnore;[/color]
      Document.Text:= list.text;
      list.free;
end.
How can I sort and delete duplicates?

PS.
I solved the problem.

Code: Select all

// Pascal script
//get links from text
// Извлечение из текста ссылок
var
  i,j: integer;
  list:TStringList;
  st:string;
begin
i := ScriptUtils.PosFrom('http://', Document.Text, 0);
list:= TStringList.Create;
Document.BeginUpdate();
      list.sorted:= true;
      list.Duplicates := dupIgnore;
while i <> 0 do
      begin
      j := i + 7;
      while not (Document.Text[j] in ['/', ' ', '''', '"', '>']) do inc(j); //тут перечисляем признаки конца домена
            st := copy(Document.Text, i, j - i);
            list.Add(st); //куда-нибудь добавляем
            i := ScriptUtils.PosFrom('http://', Document.Text, i + 1);
      end;
      MainApp.NewDocument('');
      Document.Text:= list.text;
      list.free;
Document.EndUpdate();
end.
Post Reply