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

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.