Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   [Gelöst] String in Array of Byte umwandeln [TKey] (https://www.delphipraxis.net/195476-%5Bgeloest%5D-string-array-byte-umwandeln-%5Btkey%5D.html)

Saeckel1 2. Mär 2018 22:25

Delphi-Version: 10 Berlin

[Gelöst] String in Array of Byte umwandeln [TKey]
 
Hallo, ich bräuchte mal Eure Hilfe!
Ich habe ein Problem bei der Umwandlung eines Strings in ein Array of Byte;
Ich benutze Turbo-Power OnGuard, dort gibt es einen TKey als Array [0..15] of Byte.

Delphi-Quellcode:
 Key : TKey = ($3E,$C9,$18,$78,$7D,$AC,$AF,$D3,$64,$E0,$BC,$0A,$43,$68,$2C,$F2);


Mein Key als String sieht so aus:

Delphi-Quellcode:
 S := '$3E,$C9,$18,$78,$7D,$AC,$AF,$D3,$64,$E0,$BC,$0A,$43,$68,$2C,$F2'


wie bekomme ich den String in den Key?

Danke, Saeckel1

Uwe Raabe 2. Mär 2018 22:53

AW: String in Array of Byte umwandeln [TKey]
 
Delphi-Quellcode:
var
  arr: TArray<string>;
  S: string;
  Key: TKey;
  I: Integer;
begin
  S := '$3E,$C9,$18,$78,$7D,$AC,$AF,$D3,$64,$E0,$BC,$0A,$43,$68,$2C,$F2';
  arr := S.Split([',']);
  Assert(Length(arr) = Length(Key), 'Fehler im Keystring');
  for I := 0 to Length(Key) - 1 do begin
    Key[I] := StrToInt(arr[I]);
  end;
end;

Saeckel1 3. Mär 2018 09:47

AW: String in Array of Byte umwandeln [TKey]
 
Da muss man halt die Profis fragen :-D

Funktioniert einwandfrei.

Danke!


Alle Zeitangaben in WEZ +1. Es ist jetzt 18:53 Uhr.

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