Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 22-05-2015
Avatar de bulc
bulc bulc is offline
Miembro
 
Registrado: jun 2010
Posts: 415
Poder: 14
bulc Va por buen camino
Error en el recuento de un Array

Llevo toda la tarde y no consigo ver dónde está el error. El array de Label's me da un indice sin nombre y con un elemento de más.
Un Label aparece desplazado en medio de la pantalla. Lo he comparado con otro que funciona bien y nada. Me rindo... por hoy.
A ver si vosotros veis el gazapo... Echádle un vistazo, por favor.
Código Delphi [-]
procedure TForm1.Button3Click(Sender: TObject);  // Shuffle Shape's & Label's
var
  i, a, b: Integer;   AuxLbl, AuxShp: TPoint;
begin
//ShowMessage( IntToStr( Length(Label_A)) +'  ' + IntToStr( Length(Label_A)) +'  '+ IntToStr( Length(Label_A)) );   // Muestra 25!!!
Randomize;
  for i:= Low(Label_A) to High(Label_A) - 1  do
  begin
    a:= Random(High(Shape_A)+ 1);
    b:= Random(High(Shape_A)+ 1);

    AuxShp:= Point(Shape_A[a].Left, Shape_A[a].Top);
    AuxLbl:= Point(Label_A[a].Left, Label_A[a].Top);

    Shape_A[a].Left:= Shape_A[b].Left;
    Shape_A[a].Top := Shape_A[b].Top;

    Label_A[a].Left:= Label_A[b].Left;
    Label_A[a].Top:= Label_A[b].Top;

    Shape_A[b].Left:= AuxShp.X;
    Shape_A[b].Top := AuxShp.Y;

    Label_A[b].Left:= AuxLbl.X;
    Label_A[b].Top := AuxLbl.Y;

end;

Memo2.Clear;
for I :=0 to High(Shape_A) do
begin
   Memo2.Lines.Add( 'Shape:' +InttoStr(I) + ' ' + Shape_A[i].Name + '  left  ' +   InttoStr( Shape_A[i].Left)
      +' Top ' + InttoStr( Shape_A[i].Top)  );
end;
for I := 0 to High(Label_A) do
Memo1.Clear;
for I := 0 to High(Label_A) do
  begin
  // El Indice, érroneamente, va de 0 ->24 = 25 Labels y aparece el índice 22 sin nombre, con el Top erróneo.
    Memo1.Lines.Add( 'Index: ' +IntToStr(I)  + ' ' +Label_A[i].Caption +'  Left   '+
      IntToStr(  Label_A[i].Left )+' Length '+ IntToStr(Length(Label_A))+'  T '+  IntToStr(  Label_A[i].Top )  ) ;
  end;
end;
////////////////////////////////////////////////////////
Muchas gracias por el esfuerzo. Si hace falta más código, lo envío.
Saludos.
Bulc
Responder Con Cita
 



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Error en Array Jere_84 Varios 5 26-04-2013 00:21:59
Error con Array of String orlando9427 Varios 1 25-01-2011 04:26:20
Administrador de tareas - recuento de indentificadores mole API de Windows 2 25-08-2006 09:41:52
Error en Array Trecord. alfredosg19 Varios 1 20-03-2005 16:55:04


La franja horaria es GMT +2. Ahora son las 12:29:40.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi