Cita:
Empezado por Lepuke
gracias por la ayuda ecfisa , lo que estoy haciendo es limpiar repetidos en arrays of string ...
|
Intentalo al modo de este ejemplo:
Código Delphi
[-]
type
otro_array = array of string;
function clean_array(const v: array of string): otro_array;
var
i,j: integer;
sw : Boolean;
begin
for i := Low(v) to High(v) do
begin
sw := False;
for j := i+1 to High(v) do
if v[i] = v[j] then sw := True;
if not sw then
begin
SetLength(Result, Length(Result)+1);
Result[High(Result)] := v[i];
end;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
arrays: array of string;
array_limpio: otro_array;
i: integer;
begin
SetLength(arrays, 5);
arrays[0] := 'cad1';
arrays[1] := 'cad2';
arrays[2] := 'cad1';
arrays[3] := 'cad4';
arrays[4] := 'cad1';
ListBox1.Items.Add('Todos los elementos');
ListBox1.Items.Add('---------------------------');
for i:= Low(arrays) to High(arrays) do
ListBox1.Items.Add(arrays[i]);
ListBox1.Items.Add('');
ListBox1.Items.Add('Quitando los repetidos');
ListBox1.Items.Add('---------------------------');
array_limpio := clean_array(arrays);
for i := Low(array_limpio) to High(array_limpio) do
ListBox1.Items.Add(array_limpio[i])
Finalize(arrays);
Finalize(array_limpio);
end;
Saludos