Its creating a new interface object yes, but I’m not using IInterfaceList

The Get_items is as follows :

 

function TDataSightVariableList.Get_Items(

    Index: Integer): IDataSightVariable;

begin

    with FVariableList,VarInterface do begin

        Description := Items[Index].Description;

        DisplayName := Items[Index].DisplayName;

        FieldName := Items[Index].FieldName;

        FieldID := Items[Index].FieldID;

        Units := Items[Index].Units;

        FieldFormat := Items[Index].FieldFormat;

        FieldType := integer(Items[Index].FieldType);

        Fixed := Items[Index].Fixed;

        MarkedForDelete := Items[Index].MarkedForDelete;

        MarkedForSave := Items[Index].MarkedForSave;

        Size := Items[Index].Size;

    end;

    Result := VarInterface;

end;

 

-----Original Message-----
From: Kyley Harris [mailto:[EMAIL PROTECTED]]
Sent:
Tuesday, 28 January 2003 11:54 a.m.
To: Multiple recipients of list delphi
Subject: RE: RE: RE: RE: [DUG]: Interface question

 

interesting.

 

is your Get_Items(i) creating a new interface object each time it is accessed by mistake? i would assume that in the background

you are using an IInterfaceList to contain a set of interfaces so that each subsequent call returns the same object which includes the

modified property value.

 

Get_Items(i);

begin

result := FList.Items[i] as IDisp.....

end;

 

if you use Set_Items you will lose reference to one, and gain reference to the new

-----Original Message-----
From: Matthew Evans [mailto:[EMAIL PROTECTED]]
Sent:
Tuesday, 28 January 2003 11:30 a.m.
To: Multiple recipients of list delphi
Subject: RE: RE: RE: [DUG]: Interface question

Ok this is what is happening:

Items[i].MyProp:= ‘MyValue’;

So first Get_items is called , this returns the interface with all the properties set from Fitems[i]

After the interface is returned,

Set_MyProp is called and assigned the value ‘MyValue’.

So now the interface has the new value but this interface is not returned to Items[i]

 

Not sure if this helps clear up what my problem is but I’m hoping so.

 

-----Original Message-----
From: Kyley Harris [mailto:[EMAIL PROTECTED]]
Sent:
Tuesday, 28 January 2003 10:38 a.m.
To: Multiple recipients of list delphi
Subject: RE: RE: [DUG]: Interface question

 

He isn't trying to write 'MyValue' into Set_Items in that example set_items is never called.

 

items[i].MyProp calls Get_Items(i) returning an interface. then it is trying to assign 'MyValue' to MyProp

-----Original Message-----
From: Conor Boyd [mailto:[EMAIL PROTECTED]]
Sent:
Tuesday, 28 January 2003 10:24 a.m.
To: Multiple recipients of list delphi
Subject: RE: [DUG]: Interface question

Hi Matthew,

 

Your Set_Items method is expecting a reference to an interface (IDataSightVariable).  You're passing it a string ('MyValue') in the example you gave.  The example you gave about creating an interface and setting the property values is therefore the expected behaviour.

 

Do you want to give a bit more code for us to have a look at?

 

Cheers,

 

Conor

   

-----Original Message-----
From: Matthew Evans [mailto:[EMAIL PROTECTED]]
 

Here's my problem, I have a property that returns an interface. The interface has several properties. I can read these properties fine showmessage(Items[i].MyProp); for example. However if I want to set said interface property I can't. Items[i].MyProp:= 'MyValue'; will not call the set method. So the only way I can set Interface values is first create an interface set the property values then assign it to the items list items[i]:= MyInterface;

Only been playing with these for a small amount of time and wondering how I should be going about this so I can read and write the interface properties right off the list? Any takers.

 

function Get_Items(Index: Integer): IDataSightVariable; safecall;

procedure Set_Items(Index: Integer; const Value: IDataSightVariable); safecall;

property Items[Index: Integer]: IDataSightVariable read Get_Items write Set_Items;

Reply via email to