Autor Beitrag
MagicRain
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 154

WinXp, Win8, iOS
Delphi 7, Lazarus Pascal, Delphi 10.2 Starter, NetBeans Java
BeitragVerfasst: Mo 20.06.11 14:28 
Hallo alle zusammen.

Ich habe ein Problem wo ich nicht weiter komme bzw ein denkanstoß brauche. Und Zwar möchte ich einen HexString der in meinem Editfeld eingegeben wird in eine Integer Variable ziehen und dann mit diesem wert noch weiter rechnen. Doch Irgendwie will es einfach nicht hinhauen, bzw bekomme es nicht hin.

Z.B

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
EditWert: C1CF2E29

So jetzt möchte ich immer 2 zeichen einlesen und in meine Variable schieben. Und das i := Length(String).

dh:
X : Integer;

X := C1;

nächster schleifen durchlauf 

X := CF und das so weiter bis ende Length(String).

X := 2E
...
X:= 29


Wie kann ich das umsetzen ich weiß nicht wie das gehen soll Ord geht nicht Char auch nicht. Danke für hilfe! :?: :?: :?: :?: :?: :!:
MaxWurzel
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 77
Erhaltene Danke: 10



BeitragVerfasst: Mo 20.06.11 14:43 
MagicRain Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 154

WinXp, Win8, iOS
Delphi 7, Lazarus Pascal, Delphi 10.2 Starter, NetBeans Java
BeitragVerfasst: Mo 20.06.11 14:56 
Das ist aber auch nicht ganz das was ich brauch. Den String den im im edit habe ist in Hex zb so "CC2BD8F09BB88B5DD20A4AC2458122C5D32F0EE904B1C4F869D" Und jetzt will ich immer 2 zeichen von dem wert in meine variable haben und mit dem rechnen brauch also die hex werte auch. zb so

1. Durchlauf Schleife
x = CC

x = x + x

2. Durchlaufschleife

x = nächsten 2 zeichen

x = 2B

x = x + x;

und so weiter......
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19338
Erhaltene Danke: 1752

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mo 20.06.11 15:02 
Mal so hingeschüttelt (nicht optimiert)...
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
var
  MyValue: Integer;
  MyString: string;

for i := 1 to Length(MyString) div 2 do
begin
  MyValue := StrToint('$' + Copy(MyString, i * 2 - 12));
  // do something with MyValue
end;
MagicRain Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 154

WinXp, Win8, iOS
Delphi 7, Lazarus Pascal, Delphi 10.2 Starter, NetBeans Java
BeitragVerfasst: Mo 20.06.11 15:52 
Klasse! Danke das haut hin :)

MfG