Define classes, units for scripts

Hi,

There are several at_XXX units available that can be included to get for example the unit Classes included to the script.

I would like to do the same with my own units. I've read several posts and the manual (TMS Scripter). Is it correct that you should each individual class to the atscripter? And then include all individual methods? And not create at_MyOwnUnit?

I've started with defining a simple class:

  TRandomObj = class
    protected
    private
      Frandomid       : int64;
      Ftext : string;
    published
      property randomid     : int64       read Frandomid        write Frandomid;
      property text         : string      read Ftext            write Ftext;
  end;

According to: Working with scripter | TMS Scripter documentation there is no need to register the published properties.

However the following code returns 'unkown member identifier: 'text'':

Delphi code

  atScripter1.DefineClassByRTTI(TRandomObj);
  RandomObj.text := 'testobj';
  atScripter1.AddObject('rdmobj', test);
  atScripter1.ExecuteSubRoutine('PassRandomObj', 2);

Script

procedure PassRandomObj(test);
var 
	S: string;
begin
	S := 'test';
	ShowMessage(S + rdmobj.text);
end;

When do you use:
In this case I need DefineClassByRTTI because of accessing the published properties. Correct?
When do you use AddDelphiClass?

Also, when I try to declare a TList, I get an syntax error:

procedure PassRandomObj(test);
var 
	test2 : TList<TRandomObj>;
begin
	ShowMessage('hello world');
end;

I tried to add TList, and TList<TRandomObj> via DefineClassByRTTI. But that does not work either.

Please when possible provide a sample project reproducing the issue. It saves us time. You code doesn't even compile, since this line refers to a test variable which I don't know what it is:

atScripter1.AddObject('rdmobj', test);

I took the time to try to do what you did and built a sample project, and it works fine. See attached.

Scripter_sample.zip (7.4 KB)

Generics are not supported in scripter, thus you can't use TList<T>.