Jump to content
Sign in to follow this  
dormky

How do I make a TValue for TBytes ?

Recommended Posts

I'd like to create a TValue that holds a TBytes array. From what I see of TValue's code, it doesn't seem to be designed for such, even by using variants.

 

Alternatively, if I can just get a pointer to the relevant instance field from TRttiField and cast it to a TBytes, that'll work too.

Share this post


Link to post

I see no problem to assign a TBytes to TValue. Where you find it impossible?

 

var
  v: TValue;
  a: TBytes;
begin
  setLength(a, 3);
  a[1]:=56;
  v:=TValue.From<TBytes>(a);

  ShowMessage(v.AsType<tBytes>[1].ToString);

end;

 

Share this post


Link to post

Damnit, the debugger is showing the error on the wrong line. I had an invalid typecast, but in the next block of code... Thanks :')

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×