Re: CFC defining vars

2007-08-02 Thread Kris Jones
Okay. Then it's kind of required. Ha! I always fulfill it these days anyway, just curious as to whether there would be an error thrown. I'm wondering, since someone out there threw an error by eliminating it, if there are certain cases where CF will allow the omission. When I have some time this

RE: CFC defining vars

2007-08-01 Thread Jonathon Stierman
. Jonathon -Original Message- From: Brian Kotek [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 31, 2007 1:39 PM To: CF-Talk Subject: Re: CFC defining vars The unnamed query still goes into the variables scope if you don't var scope it. I would definitely name them and var scope them. On 7/31/07

Re: CFC defining vars

2007-08-01 Thread Janet MacKay
Ugh. I wondered what had happened to those posts. I sent them a few hours ago and they never showed up. Mystery solved ;-) ~| Get the answers you are looking for on the ColdFusion Labs Forum direct from active programmers

Re: CFC defining vars

2007-08-01 Thread Tom Chiverton
On Monday 30 Jul 2007, [EMAIL PROTECTED] wrote: Why? Is this just good programming practice? Yes, because if you don't the variable isn't 'thread safe' and as soon as the CFC is under load, you'll get random errors saying it's undefined or has an impossible value. No one knows why Adobe have

Re: CFC defining vars

2007-08-01 Thread Janet MacKay
The unnamed query still goes into the variables scope if you don't var scope it So does anyone know the answer to the question If the query is unnamed, _what_ is being put into the variables scope? ~| ColdFusion is

Re: CFC defining vars

2007-08-01 Thread Brian Kotek
I poked around by dumping the variables scope, as well as getting into the underlying Java class that represents the variables scope of a CFC. On both CF7 and CF8 it appears that an unnamed query does NOT go into the variables scope. I was thinking it would go in as an unnamed variable, but as far

Re: CFC defining vars

2007-08-01 Thread Kris Jones
I haven't loaded CF8 yet, or I'd try it myself, but didn't I see someone post last week that name is a required attribute to cfquery in CF8? I poked around by dumping the variables scope, as well as getting into the underlying Java class that represents the variables scope of a CFC. On both

Re: CFC defining vars

2007-08-01 Thread Janet MacKay
didn't I see someone post last week that name is a required attribute to cfquery in CF8? Yes, according to the documentation name is now required http://livedocs.adobe.com/coldfusion/8/Tags_p-q_17.html#1102316 ~| Create

Re: CFC defining vars

2007-08-01 Thread Brian Kotek
When I tried it, it worked without name. Adobe is very careful about backward compatibility, so it's unlikely they would break something like this which probably exists (for better or worse) in a lot of existing code. On 8/1/07, Kris Jones [EMAIL PROTECTED] wrote: I haven't loaded CF8 yet, or

Re: CFC defining vars

2007-08-01 Thread Sean Corfield
On 8/1/07, Janet MacKay [EMAIL PROTECTED] wrote: Yes, according to the documentation name is now required http://livedocs.adobe.com/coldfusion/8/Tags_p-q_17.html#1102316 According to the CFMX7 docs, name was required (at least on cfquickdocs). -- Sean A Corfield -- (904) 302-SEAN An

Re: CFC defining vars

2007-08-01 Thread Janet MacKay
So it looks like you're safe. Personally I'd still name it and var scope it anyway, but then I'm paranoid. Yes, I agree with you about naming and var scoping. I'm paranoid too. I was just curious since I'd dumped the variables scope and didn't see anything other than cfquery.executionTime.

Re: CFC defining vars

2007-08-01 Thread Janet MacKay
According to the CFMX7 docs, name was required (at least on cfquickdocs). LMAO. Time for new glasses ;) I found some old documentation that says it was required as far back as CF4.5 ~| Enterprise web applications, build

Re: CFC defining vars

2007-08-01 Thread Janet MacKay
Time for new glasses I meant for me of course :-) I've always assumed name was listed as an optional attribute because CF treats it as optional. Learn something new every day. ~| Create robust enterprise, web RIAs.

Re: CFC defining vars

2007-08-01 Thread James Holmes
This is because CF8 needs somewhere to store the new return variables like the inserted RowID (if you're doing an insert) etc. On 8/2/07, Janet MacKay [EMAIL PROTECTED] wrote: didn't I see someone post last week that name is a required attribute to cfquery in CF8? Yes, according to the

Re: CFC defining vars

2007-08-01 Thread Brian Kotek
Odd, because the query runs fine without a name defined. Still, it's one more reason to var scope and name the query. This may be an oversight that will be fixed in a patch or something. On 8/2/07, Janet MacKay [EMAIL PROTECTED] wrote: didn't I see someone post last week that name is a required

RE: CFC defining vars

2007-07-31 Thread Brad Wood
] Sent: Monday, July 30, 2007 3:06 PM To: CF-Talk Subject: Re: CFC defining vars Yes, name it and var scope it. On 7/30/07, Chad Gray [EMAIL PROTECTED] wrote: I tend to do this on updates or inserts of a database records when I don't care what the query returns

Re: CFC defining vars

2007-07-31 Thread Brian Kotek
it was it. Would it really be necessary to supply, let alone var a cfquery which was only an update? ~Brad -Original Message- From: Brian Kotek [mailto:[EMAIL PROTECTED] Sent: Monday, July 30, 2007 3:06 PM To: CF-Talk Subject: Re: CFC defining vars Yes, name it and var scope

Re: CFC defining vars

2007-07-31 Thread Janet MacKay
The unnamed query still goes into the variables scope if you don't var scope it. I would definitely name them and var scope them. Okay, I don't quite understand that comment. If the query is unnamed, _what_ is being put into the variables scope?

Re: CFC defining vars

2007-07-31 Thread Janet MacKay
The unnamed query still goes into the variables scope if you don't var scope it. I would definitely name them and var scope them. I always name/var my queries but I don't understand that comment :) If the query is unnamed, _what_ is being put into the variables scope?

CFC defining vars

2007-07-30 Thread Chad Gray
I have noticed in a lot of people's code for CFCs they set all of the variables being used in the CFC like this: cfset var foo = Why? Is this just good programming practice? Also what scope are these variables in? variables.foo?

Re: CFC defining vars

2007-07-30 Thread Gualtiero Sappa
the use of var keyword is very important. Bye Gualtiero - Original Message - From: Chad Gray [EMAIL PROTECTED] To: CF-Talk cf-talk@houseoffusion.com Sent: Monday, July 30, 2007 3:46 PM Subject: CFC defining vars I have noticed in a lot of people's code for CFCs they set all

RE: CFC defining vars

2007-07-30 Thread Brad Wood
, 2007 8:46 AM To: CF-Talk Subject: CFC defining vars I have noticed in a lot of people's code for CFCs they set all of the variables being used in the CFC like this: cfset var foo = Why? Is this just good programming practice? Also what scope are these variables in? variables.foo

Re: CFC defining vars

2007-07-30 Thread Cutter (CFRelated)
The 'var' scope is for function-specific variables, that you don't want carried into the VARIABLES scope. They exist only for the lifetime of the function itself, whereas the VARIABLES scope will maintain throughout the life of the CFC instance. Steve Cutter Blades Adobe Certified Professional

Re: CFC defining vars

2007-07-30 Thread Brian Kotek
The var keyword declares the variable as local to the method, and this is probably the most critical thing that you absolutely MUST do when writing and using CFCs. Failure to do this will result in bugs and concurrency issues that will be extremely difficult to track down. So, use the var keyword

Re: CFC defining vars

2007-07-30 Thread Jake Pilgrim
Gualtiero hit the nail on the head - it allows you to define a variable (or a variable scope aka struct) who only exists for the duration of the function's processing. 'What scope is it in?' - it's in the same scope as if you omitted the 'var' keyword. cfset myVar = 'purple' / cfset var

Re: CFC defining vars

2007-07-30 Thread Charlie Griefer
using the 'var' keyword scopes the variable into the local scope *for that function/method*. so cfset var foo = / means 'foo' is available to only that method call and you don't have the potential issue of another method with a similarly named variable stomping the expected value. it's good

RE: CFC defining vars

2007-07-30 Thread Brad Wood
defining vars The var keyword declares the variable as local to the method, and this is probably the most critical thing that you absolutely MUST do when writing and using CFCs. Failure to do this will result in bugs and concurrency issues that will be extremely difficult to track down. So, use the var

Re: CFC defining vars

2007-07-30 Thread Brian Kotek
On 7/30/07, Jake Pilgrim [EMAIL PROTECTED] wrote: 'What scope is it in?' - it's in the same scope as if you omitted the 'var' keyword. cfset myVar = 'purple' / cfset var myVar = 'purple' / In both cases, your variable would be in the 'variables' scope. Jake this is not only incorrect

Re: CFC defining vars

2007-07-30 Thread Sean Corfield
On 7/30/07, Jake Pilgrim [EMAIL PROTECTED] wrote: 'What scope is it in?' - it's in the same scope as if you omitted the 'var' keyword. Nope, they are in separate scopes. cfset myVar = 'purple' / cfset var myVar = 'purple' / In both cases, your variable would be in the 'variables' scope.

Re: CFC defining vars

2007-07-30 Thread Brian Kotek
Yes, name it and var scope it. On 7/30/07, Chad Gray [EMAIL PROTECTED] wrote: Thanks for all of the info on this subject. I have fixed most of my existing code. One question I have is what happens if I don't declare a name= attribute for a cfquery? IE: cfquery

RE: CFC defining vars

2007-07-30 Thread Chad Gray
REALLY? Oh boy, I have some code to fix. :) Glad I just started using CFCs... not much code to fix. -Original Message- From: Brad Wood [mailto:[EMAIL PROTECTED] Sent: Monday, July 30, 2007 11:00 AM To: CF-Talk Subject: RE: CFC defining vars That makes the variable exist only

RE: CFC defining vars

2007-07-30 Thread Chad Gray
Thanks for all of the info on this subject. I have fixed most of my existing code. One question I have is what happens if I don't declare a name= attribute for a cfquery? IE: cfquery datasource=#application.dsn# Lots of sql here /cfquery I tend to do this on updates or inserts of a database