House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Mailing Lists
Home /  Groups /  ColdFusion Talk (CF-Talk)

Form FIELDNAME - error!!!!

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
Hi,
Chakka, Sudheer
05/09/02 04:23 P
make sure you're in a <cfoutput>...
Jeff Brown
05/09/02 04:27 P
i take that back, that shouldn't matter.
Jeff Brown
05/09/02 04:29 P
Hi Reuben,
Chakka, Sudheer
05/09/02 04:34 P
Sudheer,
Reuben Poon
05/09/02 04:41 P
Tim,
Paul Giesenhagen
05/09/02 04:37 P
<cfset variables.my_var = "query.column">
Craig Thomas
05/09/02 05:38 P
If you have:
Gyrus
05/09/02 05:42 P
I guess my example was:
Paul Giesenhagen
05/09/02 05:51 P
Paul,
Reuben Poon
05/09/02 05:58 P
Also
Timothy Heald
05/09/02 06:13 P
Ahh good point ...
Paul Giesenhagen
05/09/02 06:05 P
Hi Tim,
Chakka, Sudheer
05/09/02 04:42 P
Hi,
Chakka, Sudheer
05/09/02 05:24 P
> Hi,
Andrew Tyrone
05/09/02 05:46 P
Very cool. That's going in the snippets.
Timothy Heald
05/09/02 05:52 P
Well Guys,
Chakka, Sudheer
05/09/02 05:24 P
The cache monster strikes again :)
Timothy Heald
05/09/02 05:33 P
Hi Tim,
Chakka, Sudheer
05/09/02 05:31 P
Sudheer,
Reuben Poon
05/09/02 05:42 P
Hi Tim,
Chakka, Sudheer
05/09/02 05:37 P
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Chakka, Sudheer
05/09/2002 04:23 PM

Hi, Can any one tell me what is the mistake in      <CFLOOP FROM="1" TO="#ListLen(FORM.FIELDNAMES)#" STEP="1" INDEX="i">     <CFSET var = #ListGetAt(Form.FIELDNAMES, i)#>       #ListGetAt(Form.FIELDNAMES, i)# = #Evaluate(var)# <BR>   </CFLOOP> I am getting the following error: An error occurred while evaluating the expression: "#ListLen(FORM.FIELDNAMES)#" Any help on this is appreciated. thanks, Sudheer Chakka. ______________________________________________________________________ This list and all House of Fusion resources hosted by CFHosting.com. The place for dependable ColdFusion Hosting.

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Reuben Poon
05/09/2002 04:27 PM

If the page was called directly and not from a form submission you could get that error because no FORM fields are defined. Reuben Poon Importance: Low Hi, Can any one tell me what is the mistake in   <CFLOOP FROM="1" TO="#ListLen(FORM.FIELDNAMES)#" STEP="1" INDEX="i">     <CFSET var = #ListGetAt(Form.FIELDNAMES, i)#>       #ListGetAt(Form.FIELDNAMES, i)# = #Evaluate(var)# <BR>   </CFLOOP> I am getting the following error: An error occurred while evaluating the expression: "#ListLen(FORM.FIELDNAMES)#" Any help on this is appreciated. thanks, Sudheer Chakka. ______________________________________________________________________ This list and all House of Fusion resources hosted by CFHosting.com. The place for dependable ColdFusion Hosting.

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Jeff Brown
05/09/2002 04:27 PM

make sure you're in a <cfoutput>... v/r, Jeff Hi, Can any one tell me what is the mistake in      <CFLOOP FROM="1" TO="#ListLen(FORM.FIELDNAMES)#" STEP="1" INDEX="i">     <CFSET var = #ListGetAt(Form.FIELDNAMES, i)#>       #ListGetAt(Form.FIELDNAMES, i)# = #Evaluate(var)# <BR>   </CFLOOP> I am getting the following error: An error occurred while evaluating the expression: "#ListLen(FORM.FIELDNAMES)#" Any help on this is appreciated. thanks, Sudheer Chakka. ______________________________________________________________________ Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Jeff Brown
05/09/2002 04:29 PM

i take that back, that shouldn't matter. make sure you're in a <cfoutput>... v/r, Jeff Hi, Can any one tell me what is the mistake in      <CFLOOP FROM="1" TO="#ListLen(FORM.FIELDNAMES)#" STEP="1" INDEX="i">     <CFSET var = #ListGetAt(Form.FIELDNAMES, i)#>       #ListGetAt(Form.FIELDNAMES, i)# = #Evaluate(var)# <BR>   </CFLOOP> I am getting the following error: An error occurred while evaluating the expression: "#ListLen(FORM.FIELDNAMES)#" Any help on this is appreciated. thanks, Sudheer Chakka. ______________________________________________________________________ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Timothy Heald
05/09/2002 04:31 PM

Not sure if this is an error or just a bad practice, but you don't need the # signs in your variable declaration (cfset) <CFSET var = ListGetAt(Form.FIELDNAMES, i)> works just fine.  Also you don't need to generate that var at all you can just do a list loop like this: <CFLOOP list="#form.fieldnames#" index="formField">   #formField# = #evaluate(formField)# <CFLOOP> Tim Heald ACP/CCFD :) Application Development www.schoollink.net ----- Excess quoted text cut - see Original Post for more ----- ______________________________________________________________________ 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

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Timothy Heald
05/09/2002 04:37 PM

I made a mistake and forgot the scope.  Also you should probably have something to break it up so you can read it, like this: <CFLOOP list="#form.fieldnames#" index="formField">   #formField# = #evaluate('form' &formField)# <br /> <CFLOOP> Also someone mentioned that the cfoutput wouldn't matter, well the loop does need to be contained inside of an output for the server to process that section of the template and write the variables. Tim Heald ACP/CCFD :) Application Development www.schoollink.net ----- Excess quoted text cut - see Original Post for more ----- ______________________________________________________________________ This list and all House of Fusion resources hosted by CFHosting.com. The place for dependable ColdFusion Hosting.

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Chakka, Sudheer
05/09/2002 04:34 PM

Hi Reuben,       I am submitting using "Post" method. I am using FuseBox3. Will that make a difference?? Thanks, Sudheer Chakka    If the page was called directly and not from a form submission you could get that error because no FORM fields are defined. Reuben Poon Importance: Low Hi, Can any one tell me what is the mistake in   <CFLOOP FROM="1" TO="#ListLen(FORM.FIELDNAMES)#" STEP="1" INDEX="i">     <CFSET var = #ListGetAt(Form.FIELDNAMES, i)#>       #ListGetAt(Form.FIELDNAMES, i)# = #Evaluate(var)# <BR>   </CFLOOP> I am getting the following error: An error occurred while evaluating the expression: "#ListLen(FORM.FIELDNAMES)#" Any help on this is appreciated. thanks, Sudheer Chakka. ______________________________________________________________________ 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

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Reuben Poon
05/09/2002 04:41 PM

Sudheer, No, that should not make a difference. Do you have debugging turned on?  Look at at the FORM variables in the debugging info.  Make sure that AT LEAST ONE form variable is passed and it is listed in the fieldnames variable. Reuben Poon Importance: Low Hi Reuben,    I am submitting using "Post" method. I am using FuseBox3. Will that make a difference?? Thanks, Sudheer Chakka If the page was called directly and not from a form submission you could get that error because no FORM fields are defined. Reuben Poon Importance: Low Hi, Can any one tell me what is the mistake in   <CFLOOP FROM="1" TO="#ListLen(FORM.FIELDNAMES)#" STEP="1" INDEX="i">     <CFSET var = #ListGetAt(Form.FIELDNAMES, i)#>       #ListGetAt(Form.FIELDNAMES, i)# = #Evaluate(var)# <BR>   </CFLOOP> I am getting the following error: An error occurred while evaluating the expression: "#ListLen(FORM.FIELDNAMES)#" Any help on this is appreciated. thanks, Sudheer Chakka. ______________________________________________________________________ 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

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Timothy Heald
05/09/2002 04:44 PM

As long as you submit the form to that page you are good.  if you try and run the template directly then you will run into problems.  Using FB 3 will not cause a problem like this, but it would be best practices to use attributes scoped variables for this, not form.  The Fb 3 core files will set all url and form variables into the attributes scope. Tim Heald ACP/CCFD :) Application Development www.schoollink.net ----- Excess quoted text cut - see Original Post for more ----- ______________________________________________________________________ This list and all House of Fusion resources hosted by CFHosting.com. The place for dependable ColdFusion Hosting.

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Paul Giesenhagen
05/09/2002 04:37 PM

Tim, I wouldn't call that bad practice, It should actually be called good practice (at least in my book).  You are setting a variable and the ## around the variable show that it is a variable, makes for easier reading. Now, ## on the set side would be considered bad practice. my .02 Paul Giesenhagen QuillDesign http://www.quilldesign.com SiteDirector Commerce Builder > Not sure if this is an error or just a bad practice, but you don't need the ----- Excess quoted text cut - see Original Post for more ----- ______________________________________________________________________ Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Reuben Poon
05/09/2002 04:47 PM

I think that the # on the right side of the set operand is redundant. <CFSET my_var = #another_var#> or <CFSET my_var = another_var> There is only one thing for *another_var* to be: a variable.  If you wanted my_var to hold the string "another_var" you should quote the right hand side: <CFSET my_var = "another_var"> So my .02 is that pounds just clutter up your statement. Reuben Poon Importance: Low Tim, I wouldn't call that bad practice, It should actually be called good practice (at least in my book).  You are setting a variable and the ## around the variable show that it is a variable, makes for easier reading. Now, ## on the set side would be considered bad practice. my .02 Paul Giesenhagen QuillDesign http://www.quilldesign.com SiteDirector Commerce Builder > Not sure if this is an error or just a bad practice, but you don't need the ----- Excess quoted text cut - see Original Post for more ----- ______________________________________________________________________ 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

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Paul Giesenhagen
05/09/2002 04:56 PM

I understand your point, but it is like saying periods clutter up pages in a book. If you have: <cfset variables.my_var = "#query.column#"> That tells me that there is a variable being set and it is a string <cfset variables.my_var = "query.column"> Am I setting my variable to the two words seperated by a period, query.column? or to a variable query.column? To each his own, but it makes more sense to me to see those pounds on the right hand side ..  Plus reading a book with periods is easier too :) Paul Giesenhagen QuillDesign http://www.quilldesign.com SiteDirector Commerce Builder ----- Excess quoted text cut - see Original Post for more ----- wanted ----- Excess quoted text cut - see Original Post for more ----- can ----- Excess quoted text cut - see Original Post for more ----- ______________________________________________________________________ Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Reuben Poon
05/09/2002 05:13 PM

I'd like to continue this but I am relatively new to this forum. Are these types of debates encouraged/discouraged?  Should they be taken offline? Reuben Poon Importance: Low I understand your point, but it is like saying periods clutter up pages in a book. If you have: <cfset variables.my_var = "#query.column#"> That tells me that there is a variable being set and it is a string <cfset variables.my_var = "query.column"> Am I setting my variable to the two words seperated by a period, query.column? or to a variable query.column? To each his own, but it makes more sense to me to see those pounds on the right hand side ..  Plus reading a book with periods is easier too :) Paul Giesenhagen QuillDesign http://www.quilldesign.com SiteDirector Commerce Builder ----- Excess quoted text cut - see Original Post for more ----- wanted ----- Excess quoted text cut - see Original Post for more ----- can ----- Excess quoted text cut - see Original Post for more ----- ______________________________________________________________________ Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Timothy Heald
05/09/2002 05:17 PM

I think as long as it has something to do with CF and you don't let your emotions carry you away, that debate is acceptable, but I haven't seen any cf-talk rules or a faq or anything. Tim Heald ACP/CCFD :) Application Development www.schoollink.net ----- Excess quoted text cut - see Original Post for more ----- ______________________________________________________________________ This list and all House of Fusion resources hosted by CFHosting.com. The place for dependable ColdFusion Hosting.

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Douglas Brown
05/09/2002 05:17 PM

Nope all discussion is encouraged!!! Unless it gets ugly Douglas Brown Email: dbrown@socal.rr.com > I'd like to continue this but I am relatively new to this forum. > > Are these types of debates encouraged/discouraged?  Should they be taken ----- Excess quoted text cut - see Original Post for more ----- up pages in a > book. > > If you have: > > <cfset variables.my_var = "#query.column#"> > That tells me that there is a variable being set and it is a string ----- Excess quoted text cut - see Original Post for more ----- pounds on the > right hand side ..  Plus reading a book with periods is easier too :) ----- Excess quoted text cut - see Original Post for more ----- redundant. ----- Excess quoted text cut - see Original Post for more ----- If you > wanted > > my_var to hold the string "another_var" you should quote the right hand ----- Excess quoted text cut - see Original Post for more ----- called good > > practice (at least in my book).  You are setting a variable and the ## > > around the variable show that it is a variable, makes for easier reading. ----- Excess quoted text cut - see Original Post for more ----- don't need ----- Excess quoted text cut - see Original Post for more ----- at all you ----- Excess quoted text cut - see Original Post for more ----- INDEX="i"> ----- Excess quoted text cut - see Original Post for more ----- ______________________________________________________________________ Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Paul Giesenhagen
05/09/2002 05:22 PM

:) they are common ... they get discouraged when the go on and on ...but usually this group is very informative and you can learn alot by the debates! Paul Giesenhagen QuillDesign http://www.quilldesign.com SiteDirector Commerce Builder ----- Excess quoted text cut - see Original Post for more ----- a ----- Excess quoted text cut - see Original Post for more ----- reading. ----- Excess quoted text cut - see Original Post for more ----- need ----- Excess quoted text cut - see Original Post for more ----- ______________________________________________________________________ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Timothy Heald
05/09/2002 05:27 PM

Have we found out what the source of the original error is yet?  I love a good debate, but I would really like to help out the person who started this thread as well. Tim Heald ACP/CCFD :) Application Development www.schoollink.net ----- Excess quoted text cut - see Original Post for more ----- ______________________________________________________________________ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Craig Thomas
05/09/2002 05:38 PM

<cfset variables.my_var = "query.column"> Am I setting my variable to the two words seperated by a period, query.column? or to a variable query.column? << The first.  If you wanted to set myVar to a variable query.column, don't use quotes.  (Either way, the period should be a _ or some such.) SO, <cfset variables.myVar = "query_column"> myVar = the string "query_column" <cfset variables.myVar = query_column> sets the variable variables.myVar to some other variable, namely, query_column if it exists and throws an error if it doesn't. -Craig Thomas ______________________________________________________________________ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Reuben Poon
05/09/2002 05:41 PM

Well, I don't think it is quite like leaving out a period.  A period is a required function to denote the closing of a sentence. Pound signs are only required when a variable explicitly needs to be evaluated.  The rest of the time they are optional. And your example: <cfset variables.my_var = "#query.column#"> is flawed because if the value of query.column holds a numeric value, it will be converted to a string.  The way the statement is structured, someone reading that line would read that the intention of the statement is to assign a STRING to the variable my_var.  If the variable query.column holds a numeric value then this statement is misleading and incorrect.  Because Cold Fusion is untyped, this USUALLY does not pose problems but it could potentially cause problems. And as for your other example: <cfset variables.my_var = "query.column"> This statement puts the STRING "query.column" into the variable my_var.  You are not getting the value of the query.column variable. Reuben Poon Importance: Low I understand your point, but it is like saying periods clutter up pages in a book. If you have: <cfset variables.my_var = "#query.column#"> That tells me that there is a variable being set and it is a string <cfset variables.my_var = "query.column"> Am I setting my variable to the two words seperated by a period, query.column? or to a variable query.column? To each his own, but it makes more sense to me to see those pounds on the right hand side ..  Plus reading a book with periods is easier too :) Paul Giesenhagen QuillDesign http://www.quilldesign.com SiteDirector Commerce Builder ----- Excess quoted text cut - see Original Post for more ----- wanted ----- Excess quoted text cut - see Original Post for more ----- can ----- Excess quoted text cut - see Original Post for more ----- ______________________________________________________________________ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Gyrus
05/09/2002 05:42 PM

If you have: <cfset variables.my_var = "#query.column#"> That tells me that there is a variable being set and it is a string <cfset variables.my_var = "query.column"> Am I setting my variable to the two words seperated by a period, query.column? or to a variable query.column? --------------------------- I missed the start of this thread, but this seems like a small but important tangent to get straight... Doesn't the second CFSET set the variable to the string "query.column"? I imagine the real debate is between: <cfset variables.my_var = "#query.column#"> and <cfset variables.my_var = query.column> If we're pitching in, I usually prefer the second if your only using that variable. Studio colour coding means it's easy to see you're referring to a variable... If you're concatenating, though I find it easier to use <cfset variables.my_var = "The column value is: #query.column#"> rather than <cfset variables.my_var = "The column value is:" & query.column> Again, colour coding makes the first one easier to scan. Signing out on the "CF nit-picking" debate :-) - Gyrus ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - gyrus@rooted.freeuk.com work: http://www.tengai.co.uk play: http://www.norlonto.net - PGP key available ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ______________________________________________________________________ Get the mailserver that powers this list at http://www.coolfusion.com

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Matthew Walker
05/09/2002 05:40 PM

I vote for Reuben on this. I disagree with your argument. While you want periods in a book. You. Don't. Want. Too. Many. Of. Them. People new to CF often over use pound signs. So we are encouraged to learn when they're not needed and then not use them. Thus Reuben's and my preference for not using them when not needed. That doesn't mean it's the only right way, but it certainly is one of them. I don't understand your example: <cfset variables.my_var = "query.column"> It's obvious that you're setting your variable to the two words separated by a period. I also write things like <cfif MyQuery.RecordCount> and I think this is easier to read (for me anyway) than <cfif MyQuery.RecordCount GT 0>. Matt > I understand your point, but it is like saying periods clutter up pages in a ----- Excess quoted text cut - see Original Post for more ----- reading. ----- Excess quoted text cut - see Original Post for more ----- need ----- Excess quoted text cut - see Original Post for more ----- ______________________________________________________________________ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Timothy Heald
05/09/2002 05:45 PM

I agree.  Plus why type the extra characters.  I know on the Fb list every so often someone will voice the wish that instead of <cfoutput> you could just use <cfo>  I think that would be great :) Tim Heald ACP/CCFD :) Application Development www.schoollink.net ----- Excess quoted text cut - see Original Post for more ----- ______________________________________________________________________ This list and all House of Fusion resources hosted by CFHosting.com. The place for dependable ColdFusion Hosting.

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Paul Giesenhagen
05/09/2002 05:51 PM

I guess my example was: <cfquery datasource="dsn" name="getitems">     select first_name, last_name     from tablename </cfquery> <cfoutput>     <cfloop query="getitems">         <cfset variables.full_name = "#getitems.first_name# #getitems.last_name#">         .....OR .....         <cfset variables.first_name = "#getitems.first_name#">         .... AS opposed to...         <cfset variables.first_name = getitems.first_name>     </cfloop> </cfoutput> Now, I will say that I used to not put the #'s, but it made it easier (not cleaner) for new cf users we have to read the code, it told them that #something# was a variable and not explicit.. This is definately nit-picky ...  But I guess I am on an island :)! The speed issue?  About the same difference as <cfif vs. <cfswitch... Paul Giesenhagen QuillDesign http://www.quilldesign.com SiteDirector Commerce Builder > I vote for Reuben on this. I disagree with your argument. While you want > periods in a book. You. Don't. Want. Too. Many. Of. Them. People new to CF > often over use pound signs. So we are encouraged to learn when they're not > needed and then not use them. Thus Reuben's and my preference for not using > them when not needed. That doesn't mean it's the only right way, but it > certainly is one of them. > > I don't understand your example: <cfset variables.my_var = "query.column"> > It's obvious that you're setting your variable to the two words separated by ----- Excess quoted text cut - see Original Post for more ----- in ----- Excess quoted text cut - see Original Post for more ----- the ----- Excess quoted text cut - see Original Post for more ----- hand ----- Excess quoted text cut - see Original Post for more ----- you ----- Excess quoted text cut - see Original Post for more ----- INDEX="i"> ----- Excess quoted text cut - see Original Post for more ----- ______________________________________________________________________ Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Reuben Poon
05/09/2002 05:58 PM

Paul, Interesting point about making it easier for new CF users to read the code. I am all for making code easier to read for EVERYONE. Putting all your code into one huge file would make it easier for new CF users to read as well.  This doesn't mean it is a good idea though. In this case I think it is good to just educate the new CF users. Reuben Importance: Low I guess my example was: <cfquery datasource="dsn" name="getitems">     select first_name, last_name     from tablename </cfquery> <cfoutput>     <cfloop query="getitems">         <cfset variables.full_name = "#getitems.first_name# #getitems.last_name#">         .....OR .....         <cfset variables.first_name = "#getitems.first_name#">         .... AS opposed to...         <cfset variables.first_name = getitems.first_name>     </cfloop> </cfoutput> Now, I will say that I used to not put the #'s, but it made it easier (not cleaner) for new cf users we have to read the code, it told them that #something# was a variable and not explicit.. This is definately nit-picky ...  But I guess I am on an island :)! The speed issue?  About the same difference as <cfif vs. <cfswitch... Paul Giesenhagen QuillDesign http://www.quilldesign.com SiteDirector Commerce Builder > I vote for Reuben on this. I disagree with your argument. While you want > periods in a book. You. Don't. Want. Too. Many. Of. Them. People new to CF > often over use pound signs. So we are encouraged to learn when they're not > needed and then not use them. Thus Reuben's and my preference for not using > them when not needed. That doesn't mean it's the only right way, but it > certainly is one of them. > > I don't understand your example: <cfset variables.my_var = "query.column"> > It's obvious that you're setting your variable to the two words separated by ----- Excess quoted text cut - see Original Post for more ----- in ----- Excess quoted text cut - see Original Post for more ----- the ----- Excess quoted text cut - see Original Post for more ----- hand ----- Excess quoted text cut - see Original Post for more ----- you ----- Excess quoted text cut - see Original Post for more ----- INDEX="i"> ----- Excess quoted text cut - see Original Post for more ----- ______________________________________________________________________ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Timothy Heald
05/09/2002 05:59 PM

I would think that best practices in this case would be to allow the DB to do it's job.  I know on SQL Server I do: <cfquery datasource="#dsn#" name="getItems">      select cFirstName + ' ' + cLastName as cFullName      from tablename </cfquery> I think that may even be ansi SQL and should be availabe to most rdbms. Tim Heald ACP/CCFD :) Application Development www.schoollink.net ----- Excess quoted text cut - see Original Post for more ----- ______________________________________________________________________ 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

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Timothy Heald
05/09/2002 06:13 PM

Also > The speed issue?  About the same difference as <cfif vs. <cfswitch... The main reason I would use switch over if is to make it easer to read, and easier to maintain.  That it is faster is just a bonus.  Thats like saying: <CFSET var1 = "this"> <CFSET var2 = "that"> <CFSET var3 = "foo"> <CFSET var4 = "bar"> is better than: <CFSCRIPT>   var1 = "this";   var2 = "that";   var3 = "foo";   var4 = "bar"; </CFSCRIPT> or that in this case it wouldn't make the most sense to use: <CFSCRIPT>   var = arrayNew(4);   var[1] = "this";   var[2] = "that";   var[3] = "foo";   var[4] = "bar"; </CFSCRIPT> The third is both faster and easier to read as far as I am concerned.  Now I hear people say that the amount of time you save is so small that it's not even worth worrying about, well the way I see it is if you use ALL the fastest and most optimized code you can, then it will add up, and be noticeable.  Even if it is not noticeable to a single user, it can also help reduce your processor load on heavy hit sites.  When requests are over quicker, more requests can be processed faster and so on.  Also we shouldn't cater coding standards to the beginner, we should train and assist the beginner to the standard. My 0.02 Tim Heald ACP/CCFD :) Application Development www.schoollink.net ----- Excess quoted text cut - see Original Post for more ----- ______________________________________________________________________ This list and all House of Fusion resources hosted by CFHosting.com. The place for dependable ColdFusion Hosting.

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Paul Giesenhagen
05/09/2002 06:19 PM

And I suppose you think fusebox is a methodology......  :)   Couldn't resist .. But I agree with you that every little but helps and compound that by 50 helps and a half a million users a day .. then it makes huge differences. I am not one to stick with anything .. I have recently moved from one mehod of doing things to another ... and it was very hard for me . but in the long run it is going to pay off! My ears are always open.. Paul Giesenhagen QuillDesign http://www.quilldesign.com SiteDirector Commerce Builder > Also > > The speed issue?  About the same difference as <cfif vs. <cfswitch... > > The main reason I would use switch over if is to make it easer to read, and > easier to maintain.  That it is faster is just a bonus.  Thats like saying: ----- Excess quoted text cut - see Original Post for more ----- I > hear people say that the amount of time you save is so small that it's not > even worth worrying about, well the way I see it is if you use ALL the > fastest and most optimized code you can, then it will add up, and be > noticeable.  Even if it is not noticeable to a single user, it can also help > reduce your processor load on heavy hit sites.  When requests are over > quicker, more requests can be processed faster and so on.  Also we shouldn't ----- Excess quoted text cut - see Original Post for more ----- to ----- Excess quoted text cut - see Original Post for more ----- not ----- Excess quoted text cut - see Original Post for more ----- string ----- Excess quoted text cut - see Original Post for more ----- right ----- Excess quoted text cut - see Original Post for more ----- ______________________________________________________________________ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Paul Giesenhagen
05/09/2002 06:05 PM

Ahh good point ... (I dont think this is something to split hairs about ... but ya'll have given good points to think about!  I am not in concrete) Paul Giesenhagen QuillDesign http://www.quilldesign.com SiteDirector Commerce Builder > Paul, > > Interesting point about making it easier for new CF users to read the code. ----- Excess quoted text cut - see Original Post for more ----- CF > > often over use pound signs. So we are encouraged to learn when they're not ----- Excess quoted text cut - see Original Post for more ----- "query.column"> > > It's obvious that you're setting your variable to the two words separated ----- Excess quoted text cut - see Original Post for more ----- pages ----- Excess quoted text cut - see Original Post for more ----- redundant. ----- Excess quoted text cut - see Original Post for more ----- ## ----- Excess quoted text cut - see Original Post for more ----- ______________________________________________________________________ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Reuben Poon
05/09/2002 06:10 PM

Cool.  I'm not that nitpicky about something this inconsequential.  But it was a good conversation.  Thanks guys! Reuben Poon Importance: Low Ahh good point ... (I dont think this is something to split hairs about ... but ya'll have given good points to think about!  I am not in concrete) Paul Giesenhagen QuillDesign http://www.quilldesign.com SiteDirector Commerce Builder > Paul, > > Interesting point about making it easier for new CF users to read the code. ----- Excess quoted text cut - see Original Post for more ----- CF > > often over use pound signs. So we are encouraged to learn when they're not ----- Excess quoted text cut - see Original Post for more ----- "query.column"> > > It's obvious that you're setting your variable to the two words separated ----- Excess quoted text cut - see Original Post for more ----- pages ----- Excess quoted text cut - see Original Post for more ----- redundant. ----- Excess quoted text cut - see Original Post for more ----- ## ----- Excess quoted text cut - see Original Post for more ----- ______________________________________________________________________ Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Chakka, Sudheer
05/09/2002 04:42 PM

Hi Tim,    I checked with that code also. It is giving the same error.   An error occurred while evaluating the expression:   "#form.fieldnames#"   Error near line 3, column 17. Thanks a lot guys for all ur time. Sudheer Chakka. Not sure if this is an error or just a bad practice, but you don't need the # signs in your variable declaration (cfset) <CFSET var = ListGetAt(Form.FIELDNAMES, i)> works just fine.  Also you don't need to generate that var at all you can just do a list loop like this: <CFLOOP list="#form.fieldnames#" index="formField">   #formField# = #evaluate(formField)# <CFLOOP> Tim Heald ACP/CCFD :) Application Development www.schoollink.net ----- Excess quoted text cut - see Original Post for more ----- ______________________________________________________________________ Get the mailserver that powers this list at http://www.coolfusion.com

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Kevin Schmidt
05/09/2002 05:21 PM

Extra pound signs are a pet peeve of mine as well.  You don't need them. If you ask me, adding pound signs is like adding an additional period, not taking one away. Kevin I understand your point, but it is like saying periods clutter up pages in a book. If you have: <cfset variables.my_var = "#query.column#"> That tells me that there is a variable being set and it is a string <cfset variables.my_var = "query.column"> Am I setting my variable to the two words seperated by a period, query.column? or to a variable query.column? To each his own, but it makes more sense to me to see those pounds on the right hand side ..  Plus reading a book with periods is easier too :) Paul Giesenhagen QuillDesign http://www.quilldesign.com SiteDirector Commerce Builder ----- Excess quoted text cut - see Original Post for more ----- wanted > my_var to hold the string "another_var" you should quote the right hand ----- Excess quoted text cut - see Original Post for more ----- reading. ----- Excess quoted text cut - see Original Post for more ----- need ----- Excess quoted text cut - see Original Post for more ----- you can ----- Excess quoted text cut - see Original Post for more ----- INDEX="i"> ----- Excess quoted text cut - see Original Post for more ----- ______________________________________________________________________ Get the mailserver that powers this list at http://www.coolfusion.com

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Kevin Miller
05/09/2002 05:23 PM

Regardless of what everyone thinks, it's slower to include the pounds because CF then has to enumerate the variable's value rather than just referring to the variable itself. Kevin >>> paul@quilldesign.com 05/09/02 01:53PM >>> I understand your point, but it is like saying periods clutter up pages in a book. If you have: <cfset variables.my_var = "#query.column#"> That tells me that there is a variable being set and it is a string <cfset variables.my_var = "query.column"> Am I setting my variable to the two words seperated by a period, query.column? or to a variable query.column? To each his own, but it makes more sense to me to see those pounds on the right hand side ..  Plus reading a book with periods is easier too :) Paul Giesenhagen QuillDesign http://www.quilldesign.com SiteDirector Commerce Builder ----- Excess quoted text cut - see Original Post for more ----- wanted ----- Excess quoted text cut - see Original Post for more ----- can ----- Excess quoted text cut - see Original Post for more ----- ______________________________________________________________________ Get the mailserver that powers this list at http://www.coolfusion.com

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Chakka, Sudheer
05/09/2002 05:24 PM

Hi,    That didn't solve my problem. It is not even recognising the Form.FieldNames   <CFLOOP list="#form.fieldnames#" index="formField">     #formField# = #evaluate('form' &formField)# <br />   </CFLOOP>   it is giving error in the first line of the above code. Any more suggestions. Thanks, Sudheer Chakka. I think that the # on the right side of the set operand is redundant. <CFSET my_var = #another_var#> or <CFSET my_var = another_var> There is only one thing for *another_var* to be: a variable.  If you wanted my_var to hold the string "another_var" you should quote the right hand side: <CFSET my_var = "another_var"> So my .02 is that pounds just clutter up your statement. Reuben Poon Importance: Low Tim, I wouldn't call that bad practice, It should actually be called good practice (at least in my book).  You are setting a variable and the ## around the variable show that it is a variable, makes for easier reading. Now, ## on the set side would be considered bad practice. my .02 Paul Giesenhagen QuillDesign http://www.quilldesign.com SiteDirector Commerce Builder > Not sure if this is an error or just a bad practice, but you don't need the ----- Excess quoted text cut - see Original Post for more ----- ______________________________________________________________________ Get the mailserver that powers this list at http://www.coolfusion.com

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Andrew Tyrone
05/09/2002 05:46 PM

----- Excess quoted text cut - see Original Post for more ----- Hi there! A few things to note: As far as I know, from CF 4.5 on, the FORM scope has been a structure.  One thing I noticed about the FORM structure is that it will exist regardless of what page you are on, meaning if you click a link that goes to a page with just text (a cfm page, of course), the FORM structure is still available, just like if you had submitted a form on that previous page. That said, with the FORM scope being a structure, you can write cleaner, faster code by excluding the Evaluate() function, like so: <!--- FORM struct output, example 1 ---> <cfoutput> <cfloop list="#form.fieldnames#" index="formField">   #formField# = #FORM[formField]#<br /> </cfloop> </cfoutput> You can even go further, by looping over the FORM structure with the collection attribute in the cfloop tag: <!--- FORM struct, example 2 ---> <cfoutput> <cfloop collection="#FORM#" item="formField">   #formField# = #FORM[formField]#<br /> </cfloop> </cfoutput> Note that the second example will also display the form field "FORM.fieldnames", unlike the first example where you are actually looping over that field, which is in fact a list of all your fieldnames, except that one... Get it? ;) You can stick the second example in any page and it should work, regardless of if a form was submitted.  The FORM scope will be empty in this case.  The first requires that a form was submitted, since FORM.FIELDNAMES won't exist if a form wasn't submitted. --Andy ______________________________________________________________________ Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Timothy Heald
05/09/2002 05:52 PM

Very cool.  That's going in the snippets. Tim Heald ACP/CCFD :) Application Development www.schoollink.net ----- Excess quoted text cut - see Original Post for more ----- ______________________________________________________________________ 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

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Chakka, Sudheer
05/09/2002 05:24 PM

Well Guys,       I am Sorry!! It is weird that i closed all my opened IE Browser windows and reopened, it       worked. the same code worked !!!       Tim your code is working !! - thanks.    Guys, Thanks for all of ur patience. Special Thanks to Tim, Reuben , Paul  and everyone who participated in this discussion. Sudheer Chakka.    I think as long as it has something to do with CF and you don't let your emotions carry you away, that debate is acceptable, but I haven't seen any cf-talk rules or a faq or anything. Tim Heald ACP/CCFD :) Application Development www.schoollink.net ----- Excess quoted text cut - see Original Post for more ----- ______________________________________________________________________ Get the mailserver that powers this list at http://www.coolfusion.com

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Timothy Heald
05/09/2002 05:33 PM

The cache monster strikes again :) Tim Heald ACP/CCFD :) Application Development www.schoollink.net ----- Excess quoted text cut - see Original Post for more ----- ______________________________________________________________________ This list and all House of Fusion resources hosted by CFHosting.com. The place for dependable ColdFusion Hosting.

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Chakka, Sudheer
05/09/2002 05:31 PM

Hi Tim,    I appreciate u r concern and U will be happy to know that i could solve the problem by    closing all the opened IE browser windows and opened it and the same code is working. thanks for u r offer to help. Sudheer Chakka. Have we found out what the source of the original error is yet?  I love a good debate, but I would really like to help out the person who started this thread as well. Tim Heald ACP/CCFD :) Application Development www.schoollink.net ----- Excess quoted text cut - see Original Post for more ----- ______________________________________________________________________ Get the mailserver that powers this list at http://www.coolfusion.com

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Reuben Poon
05/09/2002 05:42 PM

Sudheer, For future reference.  The caching problem created an error probably because the FORM variables were not defined. Reuben Importance: Low Hi Tim,    I appreciate u r concern and U will be happy to know that i could solve the problem by    closing all the opened IE browser windows and opened it and the same code is working. thanks for u r offer to help. Sudheer Chakka. Have we found out what the source of the original error is yet?  I love a good debate, but I would really like to help out the person who started this thread as well. Tim Heald ACP/CCFD :) Application Development www.schoollink.net ----- Excess quoted text cut - see Original Post for more ----- ______________________________________________________________________ This list and all House of Fusion resources hosted by CFHosting.com. The place for dependable ColdFusion Hosting.

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Chakka, Sudheer
05/09/2002 05:37 PM

Hi Tim,     U know that is cache, bacuse I tried submitting the form for another form which is completely new for that session of IE and that form also didn't send the form variables.     It is kinda of bug in IE... may be I will look into more the next time if it happens!! Thanks, Sudheer Chakka. The cache monster strikes again :) Tim Heald ACP/CCFD :) Application Development www.schoollink.net ----- Excess quoted text cut - see Original Post for more ----- ______________________________________________________________________ This list and all House of Fusion resources hosted by CFHosting.com. The place for dependable ColdFusion Hosting.

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Robert Everland
05/10/2002 09:23 AM

Well when I see your code I can see right off the bat that becuase there are quotes that you're setting it to a string. I think the pounds are an extra step, it's easier  for to read, for me it's just as easy to read the quotes. To each his own. Robert Everland III Dixon Ticonderoga Web Developer Extraordinaire I understand your point, but it is like saying periods clutter up pages in a book. If you have: <cfset variables.my_var = "#query.column#"> That tells me that there is a variable being set and it is a string <cfset variables.my_var = "query.column"> Am I setting my variable to the two words seperated by a period, query.column? or to a variable query.column? To each his own, but it makes more sense to me to see those pounds on the right hand side ..  Plus reading a book with periods is easier too :) Paul Giesenhagen QuillDesign http://www.quilldesign.com SiteDirector Commerce Builder ----- Excess quoted text cut - see Original Post for more ----- wanted ----- Excess quoted text cut - see Original Post for more ----- can ----- Excess quoted text cut - see Original Post for more ----- ______________________________________________________________________ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Dave Watts
05/10/2002 02:13 PM

> I wouldn't call that bad practice, It should actually be > called good practice (at least in my book). You are setting > a variable and the ## around the variable show that it is > a variable, makes for easier reading. Now, ## on the set > side would be considered bad practice. The use of pound signs (or hashes, or whatever you like to call them) is only required when you want to output the value of a variable or an expression to a string, and in my opinion should only be used in that specific case. If you're using them for something else, it's unnecessary and may confuse developers who understand what exactly pound signs do in CF. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ voice: (202) 797-5496 fax: (202) 797-5444 ______________________________________________________________________ This list and all House of Fusion resources hosted by CFHosting.com. The place for dependable ColdFusion Hosting.

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Dave Watts
05/10/2002 02:25 PM

> > The speed issue?  About the same difference as <cfif vs. > > <cfswitch... > > The main reason I would use switch over if is to make it > easer to read, and easier to maintain. That it is faster > is just a bonus. This implies that CFSWITCH is always easier to read and maintain, and always faster. I wouldn't agree to either of those. There are cases in which it's easier to read, and other cases in which it isn't. There are cases in which it's faster, I suppose, and other cases in which it's not. I'd guess that the key in both cases is the size of your potential case table. ----- Excess quoted text cut - see Original Post for more ----- While I agree that, in this case, the last example is probably more sensible (using an array makes a concrete statement about the relationships between the values) and thus easier to read, I have no reason to believe it's faster. Do you have such a reason? ----- Excess quoted text cut - see Original Post for more ----- The problem with this statement is that you can never use ALL the fastest and most optimized code, and there are places where your optimization "bang for the buck" is almost certainly better spent. In the above example, for instance, again I have no evidence that it's any faster, or what threshold is needed to make it faster (for example, it may be faster to declare five separate variables than an array with five members, but not so for fifty separate variables vs fifty members, or vice-versa). Very often, when you see these "which is faster" debates, there just aren't any meaningful numbers used to back up these sorts of statements. There's a very good reason for this - it's hard to determine what those numbers are! On the other hand, most CF developers would find their time very well spent if they focused more on optimizing database interactions and limited the amount of runtime work - the two biggest things that will make a meaningful difference in application performance. Most developers, even those who think they have, have not done this. There's a very good reason for this as well - it's harder than focusing on CF code minutia! > Also we shouldn't cater coding standards to the beginner, we > should train and assist the beginner to the standard. Standards are nice. The best thing about them is there are so many from which to choose! Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ voice: (202) 797-5496 fax: (202) 797-5444 ______________________________________________________________________ Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm


<< Previous Thread Today's Threads Next Thread >>

Search cf-talk

September 01, 2014

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
   1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30         

Designer, Developer and mobile workflow conference