Autor Beitrag
Jean-Christoph
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 54



BeitragVerfasst: Do 05.06.03 16:08 
Also ich möchte gerne eine Eigenschaft für ein Delphi Objekt referenziert aufrufen.

Wie zum Beispiel:

Wasweisich := MyObjet.MyProperty;

Ist der normal aufruf.


MyProperty habe ich aber variabel in einer Datenbank und will die
Zuweiung so vornehmen:

MyString:= Table.FieldByName(´dbfeld’).AsString;

Wasweisich := MyObject.MyString;

Aber das geht natürlich nicht.

Wie funktioniert sowas?
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Do 05.06.03 16:13 
Schau dir mal die Methode FieldAdress an und beschäftig dich eventuell ein bisschen mit der RTTI (RunTime Type Information)...

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
Jean-Christoph Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 54



BeitragVerfasst: Do 05.06.03 18:15 
Vielen Dank für die Antwort aber Fieldaccess kennt das object nicht
und bei den RTTI vertehe ich den Zusammenhang mit meinem Problem
noch nicht
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Do 05.06.03 18:20 
Nicht FieldAccess sondern FieldAdress! ;) FieldAdress ist eine Methode von TObject und daher bei jedem Objekt verfügbar!

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
Jean-Christoph Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 54



BeitragVerfasst: Do 05.06.03 18:39 
Hallo Motzi,
entschuldige bitte, das war ein Verschreiber. ich habe FieldAdress ausprobiert aber das Objekt kennt die Methode nicht.

MyNameSpace := MyOutlook.GetNamespace('MAPI');
MyFolder := MyNameSpace.GetDefaultFolder(olFolderContacts);
dbf.dataue.Tablename:= 'UE'+trim(inttostr(nr))+'.DBF';
dbf.dataue.Databasename := sTmp+'\dataue';
dbf.dataue.open;
For i := 1 to MyFolder.Items.Count do
Begin

MyContact := (MyFolder.Items.Item(i) As _ContactItem);
dbf.dataue.first;
while not dbf.dataue.eof do
begin
if trim(dbf.dataue.FieldbyName('dbname').AsString) <> '' then
begin
Mailstring := dbf.dataue.FieldbyName('dbname').AsString;
dbf.adr.FieldByNAme(dbf.dataue.FieldbyName
('db_feld').AsString).AsString :=
///////
MyContact.FieldAdress(mailstring);
////////
end;
dbf.dataue.next;
end;

end;

finally
end;
MyOutlook.quit;

Das ist der Quellcode vielleicht erkennst Du ja wo der Fehler ist?
AXMD
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: Do 05.06.03 18:53 
Hi,

kleiner Tipp: Code-Tags/Delphi-Tags setzen!

AXMD
maximus
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 896

Win XP, Suse 8.1
Delphi 4/7/8 alles prof
BeitragVerfasst: Fr 06.06.03 10:36 
Nur zur info, warum dir rtti weiterhelfen könnte: RTTI bedeutet 'runtime type information' und du kannst damit published properties von objekten setzen/lesen, wenn du zB. den property-namen nur als string vorliegen hast...und noch vieles mehr. RTTI ist im prinzip ein haufen tabellen (records) in denen background-infos zu den klassen gespeichert sind... Also genau das, was du brauchst.

Die meisten rtti-funktionen befinden sich in der unit 'typInfo' und deine objekte sollten von TPersistent abgeleitet sein...oder mit der directive {$r+} (glaub ich) erstellt sein.

viel spass.

PS: auf dieser seite findest du eine rtti service klasse, die dir das leben einfacher machen könnte: www.joachimdevries.d...wnload/download.html

_________________
mfg.
mâximôv
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Fr 06.06.03 10:53 
Ganz genau.. über die RTTI kannst du dir die Adressen deiner properties auch selber raussuchen. Mit der Methode FielAdress wäre es halt einfacher, aber die basiert intern auch nur auf den RTTIs...

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!