Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi HexToBin (https://www.delphipraxis.net/9183-hextobin.html)

heiopei 19. Sep 2003 19:08


HexToBin
 
Abend,
welche werte muss ich bei HexToBin eingeben? - ich finds einfach nicht raus.
(angegeben ist so ungefähr :
hextobin(text, buffer: tchar; buffer_size: irgendwas

danke im vorraus,
heiopei

anku 19. Sep 2003 20:01

Re: HexToBin
 
ist das die function aus der Classes.pas?

sie wird in dieser function auf aufgerufen:
(keien ahnung ob dir das jetzt hilft..)
Delphi-Quellcode:
procedure TParser.HexToBinary(Stream: TStream);
var
  Count: Integer;
  Buffer: array[0..255] of Char;
begin
  SkipBlanks;
  while FSourcePtr^ <> '}' do
  begin
    Count := HexToBin(FSourcePtr, Buffer, SizeOf(Buffer));
    if Count = 0 then Error(SInvalidBinary);
    Stream.Write(Buffer, Count);
    Inc(FSourcePtr, Count * 2);
    SkipBlanks;
  end;
  NextToken;
end;
MfG

APP 19. Sep 2003 20:25

Re: HexToBin
 
Hallo,

na das war eine schwere Geburt!

(3 Labels auf die Form)
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);

var
  E: Extended;
  //Make sure there is room for null terminator
  Buf: array[0..SizeOf(Extended) * 2] of Char;
begin
  E := Pi;
  Label1.Caption := Format('Pi starts off as %.15f', [E]);
  BinToHex(@E, Buf, SizeOf(E));
  //Slot in the null terminator for the PChar, so we can display it easily
  Buf[SizeOf(Buf) - 1] := #0;
  Label2.Caption := Format('As text, the binary contents of Pi look like %s', [Buf]);
  //Translate just the characters, not the null terminator
  HexToBin(Buf, @E, SizeOf(Buf) - 1);
  Label3.Caption := Format('Back from text to binary, Pi is now %.15f', [E]);
end;
Quelle: http://delphi.about.com/library/rtl/blrtlHexToBin.htm


Alle Zeitangaben in WEZ +1. Es ist jetzt 03:22 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz