Frequently Asked Component Specific Questions
Options |
Display all FAQ items |
Displaying items 1 to 1 of 1, page 1 of 1
<< previous next >>
TMS Scripter
Using records defined by DefineRecordByRTTI from Delphi code
Using records defined by DefineRecordByRTTI from Delphi code
Scripter has a method named DefineRecordByRTTI which you can use from Delphi 2010 and up to define a record wrapper. It makes it easier to manipulate records, compared to the previous way which doesn’t use enhanced RTTI. When using that method, all records in scripter are represented by the TGenericRecordWrapper class. Thus when received those “records” in a Delphi method via parameter, you need to cast the object to that class and then retrieve the record pointer. Suppose your record type being wrapped is TMyRecord. You’ll need to declare a pointer to it named PMyRecord.
type PMyRecord = ^TMyRecord; procedure TatTestLibrary.__ReadRecord(AMachine: TatVirtualMachine); var MyRecord: PMyRecord; Wrapper: TGenericRecordWrapper; begin //Get the record from the script Wrapper := VarToObject(AMachine.GetInputArg(0)) as TGenericRecordWrapper; MyRecord := PMyRecord(Wrapper.Rec); // From now on you can use MyRecord to access the record. end;