Ver Mensaje Individual
  #1  
Antiguo 25-04-2015
Avatar de bulc
bulc bulc is offline
Miembro
 
Registrado: jun 2010
Posts: 416
Reputación: 15
bulc Va por buen camino
Intercambiar posiciones de varias imágenes

Hola ahí. Estoy haciendo un algoritmo para intercambiar al azar posiciones de imágenes. Ya sé hacerlo pero me gustaría automatizarlo para cualquier número o posición de ellas. Lo consigo a medias.
El caso es que dándole vueltas he llegado a la conclusión que necesito saber cómo obtener los datos de un TStringList o de un TMemo de forma progresiva para pasarlos a un Array.
Lo que tengo, de momento, es ésto y lo que quiero es sacar los datos. A ver qué atajos podéis ver... Y muchas gracias.
Código Delphi [-]
procedure TForm1.Button1Click(Sender: TObject);
Const
  ImgLeftPos_A : Array[1..8] of Integer = ( 34, 74, 114, 154, 184, 192, 204, 544);
Type
 aTSL = TStrings;
Var
   SL : aTSL;
   I, N, nAzar : Integer; // N es el nº de posiciones Left.
   sAzar : String;
   ImgLeftAzar_A : Array of Integer;
begin
   N:= 8;
   SetLength(ImgLeftAzar_A, 8);
   SL := TStringList.Create;
   Memo1.Clear;
   SL := TStringList.Create;
   repeat
            nAzar := RandomFrom( ImgLeftPos_A ) ;
            sAzar := IntToStr( nAzar ) ;
            if SL.IndexOf(sAzar) = -1  then
                begin
                SL.Add( sAzar ) ;
                Memo1.Lines.Add( sAzar ) ;
                end;
    until Memo1.Lines.Count = N ;
    SL.Free;
end;
Responder Con Cita