Board index » delphi » Properties as properties

Properties as properties

Hi all!

Is there some way I could pass a  *property*  as a parameter?!?

What I need to do (well, don't *need* really, just curious if it's possible) is pass a property
name or other reference as a parameter in order to be able to access it in another object.
The purpose is to send a list of properties and a list of corresponding field names in a
database to an object which assigns the values from the database fields to the actual
properties.

Something like

    myObject.dbObject.dbProperties := <list with propertynames and property types>
    myObject.dbObject..dbFieldNames := <list with field names and field types>

    myObject.dbObject.ReadFromDB;

and in dbObject.ReadFromDB:

    for x := 0 to dbProperties.count - 1 do
        dbProperties[x] := queryobject.fieldbyName(dbFieldNames[x]).asWhatevertype;

I realize the code above isn't  correct, but it should  illustrate what I'm looking for. I hope :-)

Any help would be appreciated!

                        Kim Johnsson

 

Re:Properties as properties


Quote
In article <48urpd$...@josie.abo.fi> kjohn...@abo.fi writes:
>From: kjohn...@abo.fi
>Subject: Properties as properties
>Date: 22 Nov 1995 09:50:37 GMT
>Hi all!
>Is there some way I could pass a  *property*  as a parameter?!?
>What I need to do (well, don't *need* really, just curious if it's possible) is pass a property
>name or other reference as a parameter in order to be able to access it in another object.
>The purpose is to send a list of properties and a list of corresponding field names in a
>database to an object which assigns the values from the database fields to the actual
>properties.
>Something like
>    myObject.dbObject.dbProperties := <list with propertynames and property types>
>    myObject.dbObject..dbFieldNames := <list with field names and field types>
>    myObject.dbObject.ReadFromDB;
>and in dbObject.ReadFromDB:
>    for x := 0 to dbProperties.count - 1 do
>        dbProperties[x] := queryobject.fieldbyName(dbFieldNames[x]).asWhatevertype;
>I realize the code above isn't  correct, but it should  illustrate what I'm looking for. I hope :-)
>Any help would be appreciated!

Sure

- a property is just another variable, effectively. So if have a new class, say

tmclass = class

property no1 : string;
property no2 : string;
end;

var
mclass : tclass;

and some proc

procedure myproc : string);

then these are all ok
myproc(no1);
myproc(no2);

as is

mclass,no1 := no2; etc

Boris Ingram, Cyborg Software
boris...@iafrica.com
http://www.pcb.co.za/users/borising/cyborg.htm

Other Threads