Ver Mensaje Individual
  #7  
Antiguo 21-07-2010
Avatar de Caral
[Caral] Caral is offline
Miembro Premium
 
Registrado: ago 2006
Posts: 7.659
Reputación: 25
Caral Va por buen camino
Hola
En la pagina que puse al principio esta un ejemplo que se acerca mas a lo que buscas, aunque siempre este en letras, define mejor la posicion.
Revisalo, tal vez te guíe algo mas:
Código Delphi [-]
type
  TCharArray = array of char; // Required below
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure FurnishDynamicArray(var typeArray : TCharArray);
????procedure ShowOpenTypeArray(typeArray : Array of char);
????procedure ShowOpenConstArray(const constArray : Array of const); 
  end;
 
var
  Form1: TForm1;
 
implementation
{$R *.dfm} // Include form definitions
 
procedure TForm1.FormCreate(Sender: TObject);
var
  // Define a dynamic array
  charArray : TCharArray;
  openArray : Array [0..2] of char;

  i : Integer;

begin
  // Pass the undefined array as a dynamic array to a subroutine
  FurnishDynamicArray(charArray);

  // Furnish an array for the next routine
  openArray[0] := 'N';
  openArray[1] := 'o';
  openArray[2] := 'w';

  // Pass this predefined array as an open array to a subroutine
  ShowOpenTypeArray(openArray);

  // Show all elements of the passed array
  for i := 0 to High(charArray) do
      ShowMessage('charArray['+intToStr(i)+'] = '+charArray[i]);

  // Pass a number of characters as an open constant array to a subroutine
  ShowOpenConstArray(['H','e','l','l','o']);
end;

// Procedure that updates a dynamic array size
// IMPORTANT - note that the array type must not be defined here -
//             we must use an array type to avoid the array being treated
//             as an open array.
procedure TForm1.FurnishDynamicArray(var typeArray : TCharArray);
var
  i : Integer;

begin
  // Set the length of the single dimension array
  SetLength(typeArray, 5);

  // Furnish this array - remember that dynamic arrays start at 0
  for i := 0 to 4 do
    typeArray[i] := Chr(Ord('A') + i);
end;

// Procedure that takes an open array
procedure TForm1.ShowOpenTypeArray(typeArray : Array of char);
var
  i : Integer;

begin
  // Show all elements of the passed array
  for i := 0 to High(typeArray) do
    ShowMessage('typeArray['+intToStr(i)+'] = '+typeArray[i]);
end;

// Procedure that takes an open constant array
procedure TForm1.ShowOpenConstArray(const constArray : Array of const);
var
  i : Integer;

begin
  // Show all elements of the passed array
  // IMPORTANT - we assume here that the constant types are all char
  //             See the TVarRec type for more on Variant types.
  for i := 0 to High(constArray) do
    ShowMessage('constArray['+intToStr(i)+'] = '+constArray[i].VChar);
end;

 
end.
Y da un mensaje con esto:
Cita:
typeArray[0] = N
typeArray[1] = o
typeArray[2] = w
charArray[0] = A
charArray[1] = B
charArray[2] = C
charArray[3] = D
charArray[4] = E
constArray[0] = H
constArray[1] = e
constArray[2] = l
constArray[3] = l
constArray[4] = o
Como veras en la posicion 1 esta o, en la 2 esta w y asi sucesivamente.
Estoy aprendiendo mucho, que bueno.
Saludos
__________________
Siempre Novato
Responder Con Cita