Did you know you can attach a function to a structure and access the
structure with the 'this' keyword?

<cfscript>
        aclient = structNew();
        aclient.myId = 32344;

        function getMyId(){
                return this.myId;
        }
        aclient.getMyId = getMyId;
</cfscript>
<cfdump var="#aclient#"/>
<cfdump var="#aclient.getMyId()#"/>

/////////////////////////////////////////////////////////
Further you can create an 'instance' of the object with struct copy and edit
the features

<cfscript>
        bclient = structCopy(aclient);
        bclient.myId = 33333;
</cfscript>
<cfdump var="#bclient#"/>
<cfdump var="#bclient.getMyId()#"/>
////////////////////////////////////////////////////////
You can also extend the object by adding more functions
<cfscript>
        function blarg(){
                return 1;
        }
        bclient.blarg = blarg;
</cfscript>
<cfdump var="#bclient#"/>

That seems pretty OO to me. You'd think Macromedia would want more people to
know about this. Or did every one else know this and I am a late bloomer?
You could do stuff like this in 5 but the 'this' was missing.

Rob

http://treebeard.sourceforge.net
http://ruinworld.sourceforge.net
Scientia Est Potentia

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.

Reply via email to