Necesito un poco de ayuda con este codigo:
procedure TForm1.OpenFileClick(Sender: TObject); var i,j,indice: integer; Str: String; begin if OpenDialog1.Execute then Edit1.Text:=OpenDialog1.FileName; Memo1.Clear; //Inicializo las columnas y filas de el stringgrid donde se inicia la escritura with TStringList.Create do try if FileExists(Edit1.Text) then begin LoadFromFile(Edit1.Text); FillChar(Buffer,Sizeof(Buffer),#255); for i:= 0 to Count - 1 do Insertar(Strings[i],Buffer); j:= StrToInt(Bufsize.caption); Str:= EmptyStr; end; begin indice := 0; //Suponiendo que buffer sea un array de 1...x for i := 1 to 255 do begin //2 renglones, cambialo a los renglones que esperas for j := 1 to 16 do begin //15 columnas stringgrid1.Cells[j,i] := inttohex(Buffer[indice],2); inc(indice); end; end; end; Str:= Str + #32 + IntToHex(Buffer[i],2); if ((i+1) mod 16 = 0) then begin Memo1.Lines.Add(Str); Str:= EmptyStr; end; if Str <> EmptyStr then Memo1.Lines.Add(Str); finally Free; end; end;
Yo tengo este codigo trabajando, pero quiero poder llenar las casillas del stringgrid sin tener que usar el Memo1.
Aqui esta la otra parte de este codigo:
function Insertar(Str: String; var Buffer: TBuffer): 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 begin Str:= Copy(Str,10,2*i); for k:= j to (j + i - 1) do begin Buffer[k]:= StrToInt('$' + Copy(Str,1,2)); Delete(Str,1,2); end; end; end;
¿Alguna idea de como lograr esto?
Un Saludo.