?
Solved

Accessing Properties of unknown object?

Posted on 1998-03-10
18
Medium Priority
?
278 Views
Last Modified: 2013-11-23
I need to create a new object of an unknown (at compiletime) object.  That's easy.  However, I then want to set any properties with the same names as the properties in my object.  How do you get a list of object properties at run time?  And how do you access them?
0
Comment
Question by:bcrotaz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 5
  • 2
  • +2
18 Comments
 
LVL 8

Expert Comment

by:ZifNab
ID: 1360373
Yo Bcrotaz,

JimBob answered a 'sort a like' of question this day... He sended some source code for it. I received it too. But, I didn't wrote it, so JimBob should earn the points. I can send you his source code, but maybe it's better to wait for JB.

Regards, Zif.
0
 
LVL 5

Expert Comment

by:JimBob091197
ID: 1360374
Hi bcrotaz & ZifNab

Zif, did u send the code to bcrotaz?  If not, and you (bcrotaz) want it, I will send it to you.  (Need your e-mail address.)

Cheers,
JB
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1360375
Hi JB, no I didn't send it to BCrotaz, because 1. I don't have BCrotaz's e-mail. 2. I was waiting for his email and would send it if it was urgent. 3. You should earn the points, not me. Regards, Zif.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 1

Author Comment

by:bcrotaz
ID: 1360376
bryan@concept-broadcast.co.uk

Thanks, JimBob.  This is what a Delphi 'Community' is all about!
0
 
LVL 5

Expert Comment

by:JimBob091197
ID: 1360377
bcrotaz:  I have sent the unit to you.

Zif: Ta.  ;-)

Cheers,
JB
0
 
LVL 3

Expert Comment

by:altena
ID: 1360378
Could you guys close the problem? It seems to me the problem
is solved and the point are paid...

(And I dont get to write an article about type-libraries...)
0
 
LVL 5

Expert Comment

by:JimBob091197
ID: 1360379
altena: Hold on a sec...  I'm just waiting for bcrotaz to evaluate the unit I sent him...
'course, if you want to write an article about type-libs, go ahead.  It's just not appropriate for this Q.

JB
0
 
LVL 3

Expert Comment

by:altena
ID: 1360380
JimBob: That means the question is "Locked" isnt it?

No type libraries? "not appropriate for this Q" really?
 In that case i would love to discuss the issue with you. Perhaps I can learn something here too...

If you want to, lets discuss this by e-mail. (the exchange
page will be a mess if we go on like this).

<AltenaR@Yahoo.com>
0
 
LVL 5

Expert Comment

by:JimBob091197
ID: 1360381
Hi Altena

The reason I said type libs are not appropriate for this Q is that brotaz initially asked "I need to create a new object..." and from the context I figured "object" meant Delphi component, not OLE object.  Whether or not OLE objects can accomplish this via T-Libs is not the point.

If you have something to ask re type libs, ask it on Ex-Ex or mail me directly at davekw@iafrica.com.

If you may have something to teach me re type libs mail me too.

In the mean time, I'll wait for brotaz to indicate that he/she is happy with the unit I sent, or if it was totally irrelevant.

JB
0
 

Expert Comment

by:bijoyn
ID: 1360382
JimBoB

Hi Again, Would u send me the unit too ?. bijoy.nair@na.manpower.com.

Thanks in advance ( again ),

Bijoy
0
 
LVL 1

Author Comment

by:bcrotaz
ID: 1360383
Well now.... I seem to have started a little war!
BTW I'm a 'He', JB.  I'm evaluating your unit tonight.
Looks like it's a bit popular.

I _am_ using Delphi objects, not components, but not OLE objects.  I thought that might introduce too much complexity to a simple problem....
0
 
LVL 5

Expert Comment

by:JimBob091197
ID: 1360384
Hi bcrotaz the 'He'   ;-)

The unit I sent you will work on any object compiled in the {$M+} state.  TPersistent is compiled in this state, so anything inherited from TPersistent (i.e. TComponent, etc.) will work with the unit I sent you.

If you want your own object (derived from TObject, etc.) to work, you must enclose the definition of the object with {$M+} and {$M-}.

E.g.
type
{$M+}
  TMyObject = class
  private
    FSomething: string;
  published
    property Something: string read FSomething write FSomething;
  end;
{$M-}

The $M+ tells Delphi to include RTTI (Run-time Type Info) for that object.  BUT the RTTI gives info only for PUBLISHED properties!!

Regards,
JB
0
 
LVL 1

Author Comment

by:bcrotaz
ID: 1360385
I knew about published properties being the only ones with RTTI.

Your unit...
i've looked through TypInfo (which I didn't know existed...!), and can't find anything about boolean properties.  Are they a special case of another type?
0
 
LVL 5

Expert Comment

by:JimBob091197
ID: 1360386
Hi

Boolean properties are treated like Integers.  If you look at the unit I sent you, I implement GetBoolValue and SetBoolValue in a very similar way to GetIntValue and SetIntValue.

JB
0
 
LVL 1

Author Comment

by:bcrotaz
ID: 1360387
u-huh. (with an Oxford English accent - of course!)
0
 
LVL 5

Expert Comment

by:JimBob091197
ID: 1360388
Hi all,

Before this question disappears into complete oblivion, shall I answer it???  I am assuming that the unit did the trick.

JB
0
 
LVL 1

Author Comment

by:bcrotaz
ID: 1360389
Yes please.
It was a good starting point.

Thanks
Bryan
0
 
LVL 5

Accepted Solution

by:
JimBob091197 earned 800 total points
ID: 1360390
This be the answer then!  ;-)

Cheers,
JB
0

Featured Post

Introducing Priority Question

Increase expert visibility of your issues by participating in Priority Question, our latest feature for Premium and Team Account holders. Adjust the priority of your question to get emergent issues in front of subject-matter experts for help when you need it most.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses
Course of the Month15 days, 6 hours left to enroll

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question