Ler memo e colocar em array.

Delphi

31/07/2007

Como faço para ler um caracter por vez de um memo e colocar em um Array de Char com tamanho igual ao total de caracteres do memo?


Leitorbinario

Leitorbinario

Curtidas 0

Respostas

Bruno Belchior

Bruno Belchior

31/07/2007

Isso deve ajudar:
function SetCharArray(pText: string): TCharArray;
var
  ret: TCharArray;
  i, lgth: Integer;
begin
  lgth := Length(pText);
  SetLength(ret,lgth);
  for i := 1 to lgth+1 do
    ret[i-1] := pText[i];
  Result := ret;
end;



GOSTEI 0
Leitorbinario

Leitorbinario

31/07/2007

Tentei usar o texto do memo na função mas deu o seguinte erro.

Undeclared identifier: ´TCharArray´
Imcompatible types


GOSTEI 0
Bruno Belchior

Bruno Belchior

31/07/2007

Isso é um tipo criado na sessão type...
type
  TCharArray = array of char;



GOSTEI 0
POSTAR