[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Accessing Properties of unknown object?

Posted on 1998-03-10
18
Medium Priority
?
281 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

650 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