[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 168
  • Last Modified:

COM & Arrays

Hi everyone...

I used the Type-Library editor to create simple record, which includes two widestrings. I want to use this record in an property which has an array. Normal Delphi code would look like this:

property Attachments[Nr : Integer] : RAttachment read GetAttachments write SetAttachments;

How can I do this?

Regards, Jonny...
0
jonnyfive
Asked:
jonnyfive
1 Solution
 
LischkeCommented:
Hi Jonny,

I have no glue so I cannot help you but I would like to know this myself.

Ciao, Mike

PS: I it at all allowed to have array properties in COM objects?
0
 
LischkeCommented:
Shouldn't that read "I have no clue..." ? (not my native language, sorry :-)).

Ciao, Mike
0
 
MadshiCommented:
Hmm... Can't you compile it the way you wrote it in your question? What does the compiler say? Perhaps I didn't understand the question?   :-))

Regards, Madshi.
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
JaymolCommented:
I don't think you can have an array for a property.

John.
0
 
MadshiCommented:
Please show us the record definition...
0
 
LischkeCommented:
Actually, you can have an array-like property in Delphi comps like:

TMyComp = class
private
  FTest: array[0..10] of PRec;
  function GetTest(Index: Integer): PRec;
  procedure SetTest(Index: Integer; R: PRec);
public
  property Test[Index: Integer]: PRec read GetTest write SetTest;
end;

function TMyComp.GetTest(Index: Integer): PRec;
begin
  Result := FTest[Index];
end;

procedure TMyComp.SetTest(Index: Integer; R: PRec);
begin
  FTest[Index] := R;
end;

This is like pretending there would be an array (indicated by the brackets in the property declaration) while it in reality just a special function.

Jonny, can you use this approach in the COM object too?

Ciao, Mike
0
 
KECommented:
Does your record definition show up in the list of available types (dropdown boxes) in the type-lib editor ?

I assume that records should be passed by reference, you may need to add an asterisk (*) to the end of the definition...

Regards
0
 
jonnyfiveAuthor Commented:
Hi Lischke...

yes I can and just did :-) Thanks for the help...

Regards, Jonny...
0
 
LischkeCommented:
:-) fine, I've learned something new too...
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now