record type methods in version 7.4

Hi Wagner,


I noticed the release notes of 7.4 said "Support for record methods when using DefineRecordByRTTI" so I have tried to add an Aurelius TBlob record to the Scripter but I still can't use it.  I am trying to use the method LoadFromStream.  I was hopping it would be available after adding 

Scripter.DefineRecordByRTTI(TypeInfo(TBlob));

but the Scripter doesn't know about it and won't compile.  I am trying to use it as follows 

Sig.Signature.LoadFromStream(Stream);  // Sig is an Aurelius object and Signature is a TBlob

If I cast as follows 

TBlob(Sig.Signature).LoadFromStream(Stream); 

it will compile and run but does nothing.  

Do you have any suggestions?

Regards

Steve

Hi Steve,


using records in Scripter is not that straightforward unfortunately. From properties, it's always safe to put the record instance in a separate variable. Can you please try this and let me know how it goes:


var Blob: TBlob;
...
Blob := Sig.Signature;
// use Blob methods here
Blob.Free;

Wagner,


Yes that works fine thank you.  Just one little change from your suggestion to create the blob rather than copy it from the property.



    Stream := TFileStream.Create(FileName, fmOpenRead); 
    Blob := TBlob.Create;
    try
      Stream.Position := 0;                     
      Blob.LoadFromStream(Stream);
      Sig.Signature := Blob;
      Manager.Save(Sig);                                     
      BI400.Commands.AFM(1,tMedium, 'Saved');  
      DeleteFile(FileName);
    finally
      Blob.Free;                         
      Stream.Free;                                          
    end;
  end;