[Volatile] FLockCount: Integer;
[Volatile] FLockCount: Integer;
The import tool can't parse attributes. The import tool is not recommended these days, as now there is the enchanted RTTI in newer Delphi versions and you can use DefineClassByRTTI to automatically register methods.
Hi Yogesh,
Hello Wagner,
thank you for your suggestion to use DefineClassByRTTI.
But "TDirectory" in System.IOUtils is defined as "TDirectory = record".
So I tried to use this statement:
Scripter.DefineRecordByRTTI(TypeInfo(TDirectory));
This compiles fine. But when I use TDirectory.GetFiles('c:\temp') from within the script-engine, the error:
Exception in classe EatScripterRuntime with message "RUNTIME ERROR File library FormUnit: Cannot execute record method. No tyoe infor available.
Did I something wrong or is your suggestion not working?
Regards,
Sam
Advanced records (class methods, for example) are not supported. In this case you will have to register it manually, defining a fake class in scripter and then defining each method manually, as a wrapper around the real class:
procedure TForm3.Button1Click(Sender: TObject);
begin
IDEScripter1.SourceCode := IDEMemo1.Lines;
IDEScripter1.Execute;
end;
procedure TForm3.FormCreate(Sender: TObject);
var
C: TatClass;
begin
C := IDEScripter1.DefineClass(TObject, 'TDirectory');
C.DefineMethod('IsEmpty', 1, tkEnumeration, nil, IsEmptyProc, True);
end;
Full source code of import tool is available under the "demos" folder.