Information générale
Catégorie:
Programmation Orientée Object
Titre:
How to build upon objects returned from methods?
When dealing with Microsoft's Outlook application, I can do the following:
oApp = createobject("Outlook.Application")
oName = oApp.GetNameSpace("MAPI")
oFolder = oName.GetDefaultFolder(3) && Task Items
* This line is the one I'm interested in
oFolder.Items(1).subject = "This is a test"
Items() is a method of the Folder object. It returns an Item object and I can continue to reference the properties and methods of that object just by tacking on the .subject, etc.
I've built a very similar class structure ... one in which an "collection" object has an items() method that returns the object that it stores; but I'm not able to access the properties and methods of the returned object in the above manner. Instead, I'm forced to do this:
oItem = oFolder.Items(1)
oItem.subject = "This is a test"
What can I do to my classes to enable the kind of "inline" syntax that I am able to use with the Outlook object?
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement