Fórum Array Dinamico como fazer um Array To Array #380708
05/07/2010
0
Exemplo:
aryNumeros : array[0..9] Of PChar ('0','1','2','3','4',...)
aryLetras : array[1..6] Of PChar ('A','B','C','D','E','F')
AryOutros : array[1..4] Of PChar (':','/','_',';')
No entando, o que eu estou querendo é que este outro deverá conter os "três primeiros arrays já pre-definidos",
Exemplo a serem incluidos em outro array tipado:
aryTextoContem : Array Of .... (aryNumeros, aryLetras, AryOutros)
Chamada:
For intCnt := Low(aryTextoContem[i][r]) To High(aryTextoContem[i][r]) Do
...
Alguém deria a solução, no caso ocorre erro ou melhor outra solução?
Jair N.
Curtir tópico
+ 0Posts
05/07/2010
Emerson Nascimento
aryTextoContem[0][0] = '0'
aryTextoContem[0][1] = '1'
aryTextoContem[0][2] = '2'
aryTextoContem[0][3] = '3'
aryTextoContem[0][4] = '4'
aryTextoContem[0][5] = '5'
aryTextoContem[0][6] = '6'
aryTextoContem[0][7] = '7'
aryTextoContem[0][8] = '8'
aryTextoContem[0][9] = '9'
aryTextoContem[1][0] = 'A'
aryTextoContem[1][1] = 'B'
aryTextoContem[1][2] = 'C'
aryTextoContem[1][3] = 'D'
aryTextoContem[1][4] = 'E'
aryTextoContem[1][5] = 'F'
aryTextoContem[2][0] = ':'
aryTextoContem[2][1] = '/'
aryTextoContem[2][2] = '_'
aryTextoContem[2][3] = ';'
ou serão apenas adicionados elementos num array simples?
aryTextoContem[0] = '0'
aryTextoContem[1] = '1'
aryTextoContem[2] = '2'
aryTextoContem[3] = '3'
aryTextoContem[4] = '4'
aryTextoContem[5] = '5'
aryTextoContem[6] = '6'
aryTextoContem[7] = '7'
aryTextoContem[8] = '8'
aryTextoContem[9] = '9'
aryTextoContem[10] = 'A'
aryTextoContem[11] = 'B'
aryTextoContem[12] = 'C'
aryTextoContem[13] = 'D'
aryTextoContem[14] = 'E'
aryTextoContem[15] = 'F'
aryTextoContem[16] = ':'
aryTextoContem[17] = '/'
aryTextoContem[18] = '_'
aryTextoContem[19] = ';'
Gostei + 0
05/07/2010
Jair N.
Gostei + 0
05/07/2010
Emerson Nascimento
const
arrayNumeros: array[0..9] Of PChar = ('0', '1', '2', '3', '4', '5', '6', '7', '8', '9');
arrayLetras: array[0..5] Of PChar = ('A','B','C','D','E','F');
arrayOutros: array[0..3] Of PChar = (':','/','_',';');
implementation
{$R *.dfm}
procedure TFormX.Button1Click(Sender: TObject);
var
arrayTudo: array of array of PChar;
i, j: integer;
procedure PreencheArray(aOrigem: array of PChar);
var
k: integer;
begin
SetLength(arrayTudo, Length(arrayTudo)+1);
for k := Low(aOrigem) to High(aOrigem) do
begin
SetLength(arrayTudo[High(arrayTudo)], Length(arrayTudo[High(arrayTudo)])+1);
arrayTudo[High(arrayTudo)][High(arrayTudo[High(arrayTudo)])] := aOrigem[k];
end;
end;
begin
PreencheArray(arrayNumeros);
PreencheArray(arrayLetras);
PreencheArray(arrayOutros);
for i := Low(arrayTudo) to High(arrayTudo) do
for j := Low(arrayTudo[i]) to High(arrayTudo[i]) do
ShowMessage(arrayTudo[i][j]);
end;
ou, se não houver obrigatoriedade de as constantes serem arrays, pode ser assim:
const
aNumeros: PChar = '0123456789';
aLetras: PChar = 'ABCDEF';
aOutros: PChar = ':/_;';
implementation
{$R *.dfm}
procedure TFormX.Button1Click(Sender: TObject);
var
aTudo: array of string;
i, j: integer;
begin
SetLength(aTudo,3);
aTudo[0] := aNumeros;
aTudo[1] := aLetras;
aTudo[2] := aOutros;
for i := Low(aTudo) to High(aTudo) do
for j := 1 to Length(aTudo[i]) do
ShowMessage(aTudo[i][j]);
end;
Gostei + 0
05/07/2010
Jair N.
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)