Ver Mensaje Individual
  #2  
Antiguo 04-06-2016
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Reputación: 38
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Hola MaxiDucoli.

Revisa este ejemplo:
Código Delphi [-]
...
implementation

function HexToBinary(const HexaValue: string):string;
const
  BIN: array [0..15] of string = ('0000','0001','0010','0011','0100','0101',
   '0110','0111','1000','1001','1010','1011','1100','1101','1110','1111');
var
  i: Integer;
begin
  for i := 1 to Length(HexaValue) do
    if not (UpCase(HexaValue[i]) in ['0'..'9','A'..'F']) then
      raise Exception.Create('Número hexadecimal inválido');

  for i := Length(HexaValue) downto 1 do
    Result := BIN[StrToInt('$' + UpCase(HexaValue[i]))] + Result;
end;

procedure SaveToFile(Hexa: string; const aFileName: TFileName);
var
  TS: TStrings;
begin
  Hexa := StringReplace(Hexa, ' ', '', [rfReplaceAll]);
  TS := TStringList.Create;
  try
    TS.Text := HexToBinary(Hexa);
    TS.SaveToFile(aFileName);
  finally
    TS.Free;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  FileName: TFileName;
  Hex: string;
begin
  Hex      := 'FF FA F1 a2 33 22 00 FF';
  FileName := ExtractFilePath(Application.ExeName) + 'binary.txt';
  SaveToFile(Hex, FileName);
end;

Saludos
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....
Responder Con Cita