I think most of the speed benefits are gone with CF5. My only problem with
cfscript is the inability to instantiate a tag object and the lack of normal
operators (++, &, this...). For the bulk of my code, I usually stick to tags
because there may be someone who doesn't understand cfscript reading my code
at some time in the future. However, when I write code where I am heavily
manipulating data, whether it be an array, structure, or just a big string,
I use cfscript almost religously. In cases like that, the keyboard mileage
savings is wonderful :)

For example, I wrote this yesterday...it just makes more sense as cfscript
imho. The rest of the template is a ton of cf/html tags, it's all about
isolating that logic :)

<cfscript>
variants = structNew();
for (i = 1; i LTE v.recordCount; i = i + 1) {
 if (NOT structKeyExists(variants, v.varGroupID[i])) {
  variants[v.varGroupID[i]] = structNew();
  variants[v.varGroupID[i]]['groupName'] = v.vGroup[i];
 }
 if (NOT structKeyExists(variants[v.varGroupID[i]], 'values')) {
  variants[v.varGroupID[i]]['values'] = structNew();
 }
 variants[v.varGroupID[i]]['groupSort'] = v.groupSort[i];
 variants[v.varGroupID[i]]['values'][v.varLabel[i]] = v.variantSort[i];
}
writeOutput(arrayToList(structSort(variants[2]['values'])));
</cfscript>

jon

----- Original Message -----
From: "Erika L. Walker-Arnold" <[EMAIL PROTECTED]>
To: "CF-Community" <[EMAIL PROTECTED]>
Sent: Tuesday, March 26, 2002 7:27 AM
Subject: RE: Looping through a recordset with CFSCRIPT Continued


> Right, but which way is faster? Cleaner? Better?
>
> With Neo coming, I'm trying to get my code as clean and efficient as
> possible ... and I was wondering if more CFSCRIPT was better than less
...
>
> Erika
> ------------------------------------------------------------
>
> >>|-----Original Message-----
> >>|From: Mike Townend [mailto:[EMAIL PROTECTED]]
> >>|Sent: 26 March 2002 12:21
> >>|To: CF-Community
> >>|Subject: RE: Looping through a recordset with CFSCRIPT Continued
> >>|
> >>|
> >>|The way ive always done it is <CFOUTPUT><CFLOOP QUERY> when ive needed
> >>|to display the information to the user and then used the CFSCRIPT loop
> >>|notation for when I need to do something with the query that isnt
> >>|displayed to the user....
> >>|
> >>|
> >>|
> >>|
> >>|-----Original Message-----
> >>|From: Erika L. Walker-Arnold [mailto:[EMAIL PROTECTED]]
> >>|Sent: 26 March 2002 12:08
> >>|To: CF-Community
> >>|Subject: Looping through a recordset with CFSCRIPT Continued
> >>|
> >>|
> >>|>From an earlier question on CF-Talk .....
> >>|
> >>|Someone wanted to loop through a recordset within a CFSCRIPT block, so
> >>|from our esteemed listmaster's docs
> >>|(http://www.houseoffusion.com/docs/cfscript.htm) we have this example
> >>|(great stuff by the way):
> >>|
> >>|<CFSCRIPT>
> >>|     For (i=1;i LTE Queryname.Recordcount; i=i+1)
> >>|          writeoutput(Queryname.Record[i]&'<BR>');
> >>|</CFSCRIPT>
> >>|
> >>|In regular CF:
> >>|
> >>|<cfloop query="queryName">
> >>|   <cfoutput>#Record#<br></cfoutput>
> >>|</cfloop>
> >>|
> >>|Which is better? Should I use CFSCRIPT for looping through and
> >>|displaying complicated data tables or continue with regular CFOUTPUT?


______________________________________________________________________
Get the mailserver that powers this list at http://www.coolfusion.com

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to