Indexed property wich returns an object

Hello!

I want to implement an class with indexed property wich returns an object.
Is it possible to implement a structure for Fastscript like this:

Room[Id].Number

Room[Id] returns an Object of Type TRoom.
TRoom has many properties... like Number, Size, Color...

The CallMethod returns a Variant type... but how do i implement a CallMethod
wich returns an Object type?

Thanks for an answer...


Comments

  • edited September 2004
    See implementation of the TStrings.Objects property (fs_iclassesrtti.pas):
    AddIndexProperty('Objects', 'Integer', 'TObject', CallMethod);

    function TFunctions.CallMethod(Instance: TObject; ClassType: TClass;
    const MethodName: String; var Params: Variant): Variant;
    begin
    if ClassType = TStrings then
    begin
    if MethodName = 'OBJECTS.GET' then
    Result := Integer(TStrings(Instance).Objects[Params[0]])
    else if MethodName = 'OBJECTS.SET' then
    TStrings(Instance).Objects[Params[0]] := TObject(Integer(Params[1]))
    end
  • wrote:

    function TFunctions.CallMethod(Instance: TObject; ClassType: TClass;
    const MethodName: String; var Params: Variant): Variant;
    begin
    if ClassType = TStrings then
    begin
    if MethodName = 'OBJECTS.GET' then
    Result := Integer(TStrings(Instance).Objects[Params[0]])
    ....

    Thanks, Result must have the IntegerType....

    Please: Develop a better Helpfile with more Examples!!!

Leave a Comment