Si lo que quieres es solamente eliminar lo que no son datos de cada linea, podemos usar una función como esta:
Código Delphi
[-]
function Strip(Str: String): String;
var
i,j,k: Integer;
begin
Result:= EmptyStr;
Str:= Trim(Str);
if Copy(Str,1,1) = ':' then
if TryStrToInt('$' + Copy(Str,2,2),i) then
if Length(Str) = ((2*i) + 11) then
if TryStrToInt('$' + Copy(Str,4,4),j) then
if TryStrToInt('$' + Copy(Str,8,2),k) then
if k = 0 then
Result:= Copy(Str,10,2*i);
end;
Y si queremos cargar todo en un memo:
Código Delphi
[-]
var
i: Integer;
Str: String;
begin
with TStringList.Create do
try
LoadFromFile('d:\test.hex');
for i:= 0 to Count - 1 do
begin
Str:= Strip(Strings[i]);
if Str <> EmptyStr then
Memo1.Lines.Add(Str);
end;
finally
Free;
end;
end;
Por otro lado lo que podemos querer en realidad es obtener todos los bytes que se van a grabar (incluidos los que no aparecen el archivo que yo supongo como ceros) y además ordenados. Eso ya es un poco, solo un poco, mas complicado ¿es eso lo que quieres?