RE: When is a struct not a struct ?
>>Hmm, so how can I reliably tell I'm holding a struct and not a CFC ? >>isStruct() and not isObject() ? I think you can tell when you are holding a struct and not a CFC like this: this is a struct this is an Object Since isObject() will only return true if it is an object, if you check both of them to confirm you have a structure, you will know for sure. Of course, if you just interrogate isStruct() then you won't know for sure, but if you check both, you will since we have proven that isObject() returns false on a structure, even if you have loaded it with functions to make it LOOK like an object. Of course, if you're checking to see if something is an object, you don't have to check both, you can just do isObject(), but in your case, I think you want to know if it is a structure and I think based on what we've seen, to be 100% sure, you have to do both. Dave ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:310200 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: When is a struct not a struct ?
On Monday 04 Aug 2008, Brian Kotek wrote: > CFCs can also be treated as structures for most purposes. > StructKeyExists(), StructKeyList(), etc. will all work on a CFC instance. Hmm, so how can I reliably tell I'm holding a struct and not a CFC ? isStruct() and not isObject() ? -- Tom Chiverton This email is sent for and on behalf of Halliwells LLP. Halliwells LLP is a limited liability partnership registered in England and Wales under registered number OC307980 whose registered office address is at Halliwells LLP, 3 Hardman Square, Spinningfields, Manchester, M3 3EB. A list of members is available for inspection at the registered office. Any reference to a partner in relation to Halliwells LLP means a member of Halliwells LLP. Regulated by The Solicitors Regulation Authority. CONFIDENTIALITY This email is intended only for the use of the addressee named above and may be confidential or legally privileged. If you are not the addressee you must not read it and must not use any information contained in nor copy it nor inform any person other than Halliwells LLP or the addressee of its existence or contents. If you have received this email in error please delete it and notify Halliwells LLP IT Department on 0870 365 2500. For more information about Halliwells LLP visit www.halliwells.com. ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:310192 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: When is a struct not a struct ?
CFCs can also be treated as structures for most purposes. StructKeyExists(), StructKeyList(), etc. will all work on a CFC instance. On Mon, Aug 4, 2008 at 7:31 AM, Tom Chiverton <[EMAIL PROTECTED]>wrote: > When is a struct (as given by isStruct()) not a struct ? > Answer: When it's a (value) object > > The following code creates an object with a few simple properties, and > dumps > this OK as an object i.e. component. > It then says that this is a struct, before confirming again it's an object > ! > > Is CF meant to work that way, because it's a tad confusing if so > > > > > > > CF 8.01 if that helps. > -- > Tom Chiverton > > > > This email is sent for and on behalf of Halliwells LLP. > > Halliwells LLP is a limited liability partnership registered in England and > Wales under registered number OC307980 whose registered office address is at > Halliwells LLP, 3 Hardman Square, Spinningfields, Manchester, M3 3EB. A > list of members is available for inspection at the registered office. Any > reference to a partner in relation to Halliwells LLP means a member of > Halliwells LLP. Regulated by The Solicitors Regulation Authority. > > CONFIDENTIALITY > > This email is intended only for the use of the addressee named above and > may be confidential or legally privileged. If you are not the addressee you > must not read it and must not use any information contained in nor copy it > nor inform any person other than Halliwells LLP or the addressee of its > existence or contents. If you have received this email in error please > delete it and notify Halliwells LLP IT Department on 0870 365 2500. > > For more information about Halliwells LLP visit www.halliwells.com. > > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:310165 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: When is a struct not a struct ?
>> From my understanding, I thought an object was a special kind of structure - a structure with processes (methods). On the other hand, it may look and act like an object, but it isn't one. The code below shows that you can create a structure that 'looks' like an object, (with what appears to be a method, but is really just a reference to a UDF), but doesn't return true for isObject(). I think this is right behavior. This is also a good example of why it's good to prefix variables because if you saw stDate.getDate() without st in front of it, you would probably start looking for a createObject() function somewhere but would never find it. #isStruct(stDate)# #isObject(stDate)# #stDate.getDate()# ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:310114 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: When is a struct not a struct ?
> The following code creates an object with a few simple properties, and > dumps > this OK as an object i.e. component. > It then says that this is a struct, before confirming again it's an > object ! >From my understanding, I thought an object was a special kind of structure - a >structure with processes (methods). Will ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:310113 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: When is a struct not a struct?
When you call duplicate(cfcatch) it returns a structure. Then you can pass it to a UDF where the argument type is struct and use all struct functions on it. That's also how cfdump works. If it gets an exception, it duplicates it. HTH, Sam --- Blog: http://www.rewindlife.com Charts: http://www.blinex.com/products/charting --- #duplicate(cfcatch).getClass().toString()# > -Original Message- > From: Craig Earls [mailto:[EMAIL PROTECTED] > Sent: Friday, February 06, 2004 10:31 PM > To: CF-Talk > Subject: When is a struct not a struct? > > If you inside a CFCATCH > block you will see a nicely block structured "struct". > However if you try to pass #CFCATCH# inside a > cfinvokeargument that requires a struct, it pukes. You can't > use StructCopy on it, so what is CFCATCH? Is there anyway to > capture it as a Struct that can be passed? > [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: When is a struct not a struct?
You might try creating an empty struct and then setting the CFCATCH into it: foo = structNew(); foo = cfcatch; Alternately, you could just use the new struct as a wrapper: foo = structNew(); foor['error'] = cfcatch; I haven't tried either, but if the first doesn't work, the second almost certainly will. you'll just have to unwrap the error on the other side... -Cameron - Cameron Childress Sumo Consulting Inc --- land: 858.509.3098 cell: 678.637.5072 aim: cameroncf email: [EMAIL PROTECTED] -Original Message- From: Craig Earls [mailto:[EMAIL PROTECTED] Sent: Friday, February 06, 2004 7:31 PM To: CF-Talk Subject: When is a struct not a struct? If you inside a CFCATCH block you will see a nicely block structured "struct". However if you try to pass #CFCATCH# inside a cfinvokeargument that requires a struct, it pukes. You can't use StructCopy on it, so what is CFCATCH? Is there anyway to capture it as a Struct that can be passed? [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: When is a struct not a struct?
#cfcatch.getClass().toString()# returns "class coldfusion.runtime.CustomException" #s.getClass().toString()# returns "class coldfusion.runtime.Struct" -nathan strutz -Original Message- From: Craig Earls [mailto:[EMAIL PROTECTED] Sent: Friday, February 06, 2004 8:31 PM To: CF-Talk Subject: When is a struct not a struct? If you inside a CFCATCH block you will see a nicely block structured "struct". However if you try to pass #CFCATCH# inside a cfinvokeargument that requires a struct, it pukes. You can't use StructCopy on it, so what is CFCATCH? Is there anyway to capture it as a Struct that can be passed? [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]