I'm trying to increment an hex string like this:
#$67#$1c#$87#$b1; #$67#$1c#$87#$b2; #$67#$1c#$87#$b3;
Here's my procedure:
var test : array [0..3] of char; intSequence : cardinal;
Sequence := #$67#$1c#$87#$b1;
procedure IncSequence;
begin
move(Sequence[1],intSequence,SizeOF(Sequence));
inc(intSequence);
move(intSequence,Sequence[1],SizeOf(test));
end;
Whith this procedure, only the second byte increment. The result is:
#$67#$1D#$87#$B1 #$67#$1E#$87#$B1 #$67#$1F#$87#$B1
Thanks
You could also do this by creating a "variant record" and just using Inc();
type
testrec = record
case Byte of
0: (data: array[0..3] of AnsiChar);
1: (intSequence: Integer);
end;
var
Sequence: testrec;
begin
Sequence.data = #$b1#$87#$1c#$67; // reversed because of "endian-ness"
Inc(Sequence.intSequence);
end;
In this case, the data and intSequence fields "overlay" each other in memory, so any writes to one field will immediately reflect in the other.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With