Ver Mensaje Individual
  #8  
Antiguo 17-07-2014
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Reputación: 36
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Vamos por otro...

Código Delphi [-]
...
uses contnrs;

type
  TRecStr = record
    s1,s2: string;
  end;

var
  List: TList;

procedure TForm1.FormCreate(Sender: TObject);
var
  PR: ^TRecStr;
begin
  List:= TList.Create;
  with qryTiposServicios do
  begin
    Open;
    while not Eof do
    begin
      New(PR);
      PR.s1:= FieldByName('TIPO').AsString;
      PR.s2:= FieldByName('DESCRIPCION').AsString;
      List.Add(PR);
      Next;
    end;
  end;
end;

procedure TForm1.btnShowClick(Sender: TObject);
var
  i: Integer;
begin
  for i:= 0 to List.Count-1 do
    ListBox1.Items.Add(Format('%s - %s',
      [TRecStr(List[i]^).s1,TRecStr(List[i]^).s2]));
end;

procedure TForm1.FormDestroy(Sender: TObject);
var
  i: Integer;
begin
  for i:= 0 to List.Count-1 do
    Dispose(List.Items[i]);
  List.Free;
end;

Y otro:
Código Delphi [-]
uses contnrs;

type
  PRecStr = ^TRecStr;
  TRecStr = record
    s1, s2: string;
  end;

var
  Queue: TQueue;

procedure TForm1.FormCreate(Sender: TObject);
var
   PR: PRecStr;
begin
  Queue:= TQueue.Create;
  with qryTiposServicios do
  begin
    Open;
    while not Eof do
    begin
      New(PR);
      PR.s1:= FieldByName('TIPO').AsString;
      PR.s2:= FieldByName('DESCRIPCION').AsString;
      Queue.Push(PR);
      Next;
    end;
  end;
end;

procedure TForm1.btnShowClick(Sender: TObject);
var
  i: Integer;
  R: PRecStr;
begin
  while Queue.Count > 0 do
  begin
    R:= Queue.Pop;
    ListBox1.Items.Add(Format('%s - %s', [R^.s1, R^.s2]));
  end;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  Queue.Free;
end;

...

Saludos
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....
Responder Con Cita