Author Topic: Delphi problem  (Read 2684 times)

Alex

  • EA Novice
  • *
  • Posts: 2
  • Karma: +1/-0
    • View Profile
Delphi problem
« on: May 19, 2005, 01:48:58 pm »
Hi,

I can connect to repository, load tree of packages, for each package I can load list of elements, but
1) All elements have empty stereotype;
2) element's TaggedValues collection is always NIL;
3) I have access violation error while access to element's Methods or Attributes collections.

The next is my simplified code

procedure ShowPackage(pkg: IPackage);
var
 i: integer;
 coll: ICollection;
begin
 Memo1.lines.Add(pkg.Name);
 coll := pkg.Elements as ICollection;
 for i:=0 to coll.Count-1 do
   ShowElement(coll.GetAt(i) as IElement);
end;

procedure ShowElement(elm: IElement);
var
 i: integer;
 coll: ICollection;
 tv: ITaggedValue;
 d: IDispatch;
begin
 Memo1.lines.Add(elm.Name);         // works fine
 Memo1.lines.Add(elm.Stereotype); // always blank :(

 coll := elm.TaggedValues as ICollection;
 if coll<>nil then                               // always NIL :(
   for i:=0 to coll.Count-1 do ;

 d := elm.Methods;
 coll := d as ICollection;          // access violation error :(
 d := elm.Attributes;
 coll := d as ICollection;          // access violation error :(
end;

Thanks,
Alexander Zemerov.

azemerov

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Delphi problem
« Reply #1 on: May 20, 2005, 03:02:44 pm »
Solved!

After I replaced interface types in my code to "Dual" ones (i.e. ICollection -> IDualCollection) everething is fine.

In EA_TLB.pas ICollection is declared as "dispinterface" and IDualCollection is declared as "interface (IDispatch)".

I'm not proficient in COM, so if enybody can explain while dispinterface doesn't work, I will be glad.

Alexander Zemerov.
« Last Edit: May 20, 2005, 03:05:35 pm by azemerov »