Yeah, this showed up on the list in one of the Macromedia guys (Sean, I think) 
responses in passing.

----- Original Message -----
From: Rob Rohan <[EMAIL PROTECTED]>
Date: Tuesday, December 3, 2002 4:37 pm
Subject: Objects in CF

> 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
Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm

Reply via email to