cfcomponent
cfscript
function myFunc...
return resultVar
/cfscript
That method nets function myFunc not found.
It's been a while since I've played with CFC's, but from what I
remember, that should work. Are you calling object.myfunc()?
That method gets me a variable myArg
and CFMX;
my life would be simpler if I could talk my way into a second MX license...
-Original Message-
From: Jared Rypka-Hauer - CMG, LLC [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 02, 2005 10:20 PM
To: CF-Talk
Subject: Re: cfscript functions in CFCs
This also works:
test.cfc
Well this syntax is invalid -- if your psuedocode is accurate... You
can't declare a function within a function. Or that was what I thought
You're right - my function-within-a-function code block caused an error on
CFMX server. It does seem like a pretty silly idea after having it pointed
])/
/cffunction
/cfcomponent
test2.cfc
-
cfcomponent
cfscript
function getCGI(cV) {
var cVlocal = '';
if (len(cV)) {
cVlocal = cgi[cV
This was a fun, if simple, excercise... thanks Paul!
For as often as I'm confused, it's nice that at least my questions at least
occasionally lead to something positive for someone out there! Thanks for
looking into it, as well.
:20:25 -0600, Jared Rypka-Hauer - CMG, LLC
[EMAIL PROTECTED] wrote:
This also works:
test.cfc
-
cfcomponent
cfscript
function getCGI(cV) {
try {
return cgi[cV
that perspective, you could create a var'ed structure, loop the
arguments structure and write all the argument variables to the local
structure, and then use structKeyExists for detecting their presence
for conditional processing:
cfscript
function myFunction() {
var myContainer = structNew
This must be easier than I'm making it this afternoon.
All the UDFs from cflib.org are written in cfscript. Is there a way to
store them in a CFC, say Util.cfc, and then call them from another CFC?
When I attempt to do so CF can't find the function. I experimented and
wrapped the cfscript
This must be easier than I'm making it this afternoon.
All the UDFs from cflib.org are written in cfscript. Is
there a way to
store them in a CFC, say Util.cfc, and then call them from
another CFC?
When I attempt to do so CF can't find the function. I
experimented and
wrapped
You'd have to either convert the argument list from the function to
cfargument tags or you can inject the created function into the cfc
like this:
What I'm trying is similar to what you suggest:
cfcomponent
cfscript
function myFunc...
return resultVar
/cfscript
That method
cfcomponent
cffunction name=myFunc
cfargument name=myArg required=Yes
cfscript
function myFunc2...
return resultVar
/cfscript
cfreturn myFunc2(arguments.myArg)
/cffunction
That method gets me a variable myArg is undefined
message, curiously
This works:
test.cfc
---
cfcomponent
cfscript
function getCGI() {
return cgi;
}
/cfscript
/cfcomponent
temp.cfm
--
cfdump var=#createObject('component
This also works:
test.cfc
-
cfcomponent
cfscript
function getCGI(cV) {
try {
return cgi[cV];
}
catch (any cfScriptError
Hehe, apparently I'm replying to this message in stages... I've been
playing with this.
So... according to the cf documentation, all args specified in the
function declaration are mandatory. It seems that the only way to use
optional arguments in cfscript function arguments is to use a try
block
Anyone know if there's a way to write plain old java inside CFM files?
I was thinking something like this:
CFSCRIPT language=java
plain and simple java code
/CFSCRIPT
Just curious
NOTICE: If received in error, please destroy
Anyone know if there's a way to write plain old java inside CFM files?
I was thinking something like this:
CFSCRIPT language=java
plain and simple java code
/CFSCRIPT
To the best of my knowledge, no. However, you can just write Java classes
then call them from within CF.
Dave Watts, CTO
I think you need to escape (i.e. double up) the single quotes in any
CF vars you're using in the query, then use preservesinglequotes()
inside cfquery tag.
cfscript
mySQLstring = SELECT orders_id FROM Orders WHERE label =
'#Replace(This_Label, ', '', all)#';
/cfscript
cfquery name=qwe
I use preserveSingleQuotes with MySQL without any issue. You
shouldn't need to do anything special:
cfset sql = select * from mytable where name = 'barneyb' /
cfquery ...
#preserveSingleQuotes(sql)#
/cfquery
On Wed, 8 Dec 2004 18:08:02 -0500, C. Hatton Humphrey
[EMAIL PROTECTED] wrote:
If you're using CF variables in your SQL you may* need to escape any
single quotes when you're creating your SQL statement in the first
place:
cfset user = Barney O'Boivert
cfset sql = select * from mytable where name = '#Replace(user, ',
'', all))#' /
cfquery ...
#preserveSingleQuotes(sql)#
Okay, to try and make my life easier I decided to try changing a block
of code from CFSet to CFScript.
However, part of what I need to do in this code is run a query based
on a variable value... I'm pulling a label out of a record body and
need to get the id of a record where a certian field
What database are you using? preserveSingleQuotes() has always worked
for me, exactly as intended.
However, before you go too far down this road, I'd recommend not using
CFSCRIPT for this code, because there is a query inside. Sure, you
can make a wrapper, as you tried, but doing
Why not just double up the single quotes?
Okay, to try and make my life easier I decided to try changing a
block
of code from CFSet to CFScript.
However, part of what I need to do in this code is run a query based
on a variable value... I'm pulling a label out of a record body and
need
Why not just double up the single quotes?
Tried that - may be a NDA thing or just a MySQL thing - I got the same
error when sending the query.
To answer Barney's question - I'm using a MySQL database. That's what
the clent has and I haven't been able to dissuade him from using it.
When I sent
Does anybody know any good resources for writing scripts inside of the cfscript
tag? I found something on macromedia's live doc's site but it wasn't very easy
to follow. Specifically i'm looking for loops, handling arrays, and handling
cfc's as objects.
Thanks,
Ryan
, though with the CF
built-in functions, rather than the JavaScript ones.
cheers,
barneyb
On Wed, 10 Nov 2004 18:20:53 -0400, Ryan Anklam [EMAIL PROTECTED] wrote:
Does anybody know any good resources for writing scripts inside of the
cfscript tag? I found something on macromedia's live doc's site
i've got a very introductory cfscript tutorial up on easycfm. a
couple on arrays and structs, but those aren't in cfscript contexts.
http://www.easycfm.com/tutorials/authors.cfm?Author=Charlie%20Griefer%20%28CJ%29
maybe they'll give you a little something to go on at least.
On Wed, 10 Nov
http://www.houseoffusion.com/script.ppt
Covers the basic constructs. One trick not covered is a query loop
cfquery ... name=myQuery
... sql goes here...
/cfquery
cfscript
LoopStep=1;
do {
// stuff
LoopStep=LoopStep+1;
} while (LoopStep LTE myQuery.RecordCount);
/cfscript
You can play
Won't that loop break if you have a zero-row recordset? This one
won't, and is more readable (I think), and less prone to forgetting
that increment line in the middle.
cfscript
for (LoopStep = 1; LoopStep myQuery.recordCount; LoopStep = LoopStep + 1) {
// stuff
}
/cfscript
cheers,
barneyb
Also
http://www.houseoffusion.com/docs/cfscript.htm
This covers all the loops and is only missing try/catch
http://www.houseoffusion.com/script.ppt
Covers the basic constructs. One trick not covered is a query loop
cfquery ... name=myQuery
... sql goes here...
/cfquery
cfscript
I've never been a fan of for loops. Just a personal pref on my part.
I deal with zero recordsets by surrounding the loop in if
(myquery.recordcount gt 0) { blah }.
And of course you cannot use '' as an operator, and its equivalent,
LT, would exclude the last record in the set, but I get the idea
Yeah, you're right. should be LTE, not . I make that mistake a
lot, because CF is both one-indexed, and uses weird-ass operators.
Why oh why couldn't it just be normal like JS, AS, Java, C, Perl, PHP,
etc. etc. ;) I'd include SQL in there, but it's hardly normal,
though way more normal than
Hi Everyone.
Does anyone know how to loop within CFSCRIPT over a query and/or a
comma list, like you can with CFLOOP?
Also, does anyone konw if there is a good guide to CFSCRIPT anywhere
as the MM documentation of CFSCRIPT is pretty much none existant.
Thanks
Andrew.
[Todays Threads
funny u mention that.. i was just looking today and came across this
http://www.houseoffusion.com/script.ppt and
http://tutorial84.easycfm.com/
you can use FOR and WHILE loops .. its in the ppt above
get some caffine try to google: cfscript
joe velez
[Todays Threads]
[This Message
i havent actually played w/ cfscript too much, but in reading about it briefly i believe its something like this
for a comma del. list
cfscript
var=0; /* not sure if var = 0 if you dont set it first, you can probably exclude this, but set it to be safe */
while(VAR lte listlen(yourlist
Thanks...
- Original Message -
From: joe velez [EMAIL PROTECTED]
Date: Thu, 09 Sep 2004 06:03:47 -0400
Subject: Re: Looping in CFSCRIPT
To: CF-Talk [EMAIL PROTECTED]
i havent actually played w/ cfscript too much, but in reading about it
briefly i believe its something like
Here's my write up on using cfscript for looping over a query:
http://gregs.tcias.co.uk/cold_fusion/outputting_queries_with_cfscript.php
Hope this helps
G
On Thu, 9 Sep 2004 10:42:18 +0100, Andrew Dixon [EMAIL PROTECTED] wrote:
Hi Everyone.
Does anyone know how to loop within CFSCRIPT over
come on G .. php??? hehe
=^) -- that's for Carsten god .. you know who you are!
[Todays Threads]
[This Message]
[Subscription]
[Fast Unsubscribe]
[User Settings]
[Donations and Support]
He has a point!!!
- Original Message -
From: joe velez [EMAIL PROTECTED]
Date: Thu, 09 Sep 2004 06:20:23 -0400
Subject: Re: Looping in CFSCRIPT
To: CF-Talk [EMAIL PROTECTED]
come on G .. php??? hehe
=^) -- that's for Carsten god .. you know who you
: Looping in CFSCRIPT
Hi Everyone.
Does anyone know how to loop within CFSCRIPT over a query and/or a
comma list, like you can with CFLOOP?
Also, does anyone konw if there is a good guide to CFSCRIPT anywhere
as the MM documentation of CFSCRIPT is pretty much none existant.
Thanks
Andrew
Here is a starting point.
http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/cfscript.htm
Doug
Andrew Dixon wrote:
Hi Everyone.
Does anyone know how to loop within CFSCRIPT over a query and/or a
comma list, like you can with CFLOOP?
Also, does anyone konw if there is a good guide
xon [EMAIL PROTECTED] wrote:
He has a point!!!
- Original Message -
From: joe velez [EMAIL PROTECTED]
Date: Thu, 09 Sep 2004 06:20:23 -0400
Subject: Re: Looping in CFSCRIPT
To: CF-Talk [EMAIL PROTECTED]
come on G .. php??? hehe
=^) -- that's for Carsten god .. you know who
I wanted to use a function to determine the checked state of a
checkbox, so I made a function within a CFScript area.But if I use
FindNoCase in it, it no longer works.If I change out the FindNoCase
with the number 1 it works fine.Is it that this is a cf function
that's not allowed in cfscript
state of a
checkbox, so I made a function within a CFScript area.But if I use
FindNoCase in it, it no longer works.If I change out the FindNoCase
with the number 1 it works fine.Is it that this is a cf function
that's not allowed in cfscript and if so, what now?
cfscript
function setChecked
doh.thanks.It works fine now.
You're searching for a literal the_val in the string, not the passed
value of the the_val variable.Remove those quotes and you should be
good to go.
[Todays Threads]
[This Message]
[Subscription]
[Fast Unsubscribe]
[User Settings]
[Donations and Support]
I'm trying to do a CFQuery from within a cfscript and it's not working.I'm using the latest CFMX 6.1 and I'm basing my code off of this article:
http://www.macromedia.com/devnet/mx/coldfusion/extreme/cftags_cfscript.html
However, when I call my function I the following error:
Variable CFQUERY
Post the code.
Any ideas?
[Todays Threads]
[This Message]
[Subscription]
[Fast Unsubscribe]
[User Settings]
[Donations and Support]
, 18 Aug 2004 10:20:36 -0400, Howie Hamlin [EMAIL PROTECTED] wrote:
I'm trying to do a CFQuery from within a cfscript and it's not working.I'm using the latest CFMX 6.1 and I'm basing my code off of this article:
http://www.macromedia.com/devnet/mx/coldfusion/extreme/cftags_cfscript.html
Here is the code (it's supposed to log to a table):
CFSCRIPT
function CSLog(CustomerID,Category,SubCategory,I0,I1,I2,I3,I4,Description){
try{
SQLString = Insert into Log (Category,SubCategory,I0,I1,I2,I3,I4,Description,When) Values
(#Arguments.Category#,#Arguments.SubCategory#,'#Arguments.I0
, August 18, 2004 10:29 AM
Subject: Re: Query from within a cfscript
Hi,
Could you post your code?
In the meantime, here is how I went about it:
http://gregs.tcias.co.uk/cold_fusion/outputting_queries_with_cfscript.php
I based it on the same example but opted for placing the query in a
CFC
Have you got a function of your own called CFQuery()?
Ade
-Original Message-
From: Howie Hamlin [mailto:[EMAIL PROTECTED]
Sent: 18 August 2004 15:31
To: CF-Talk
Subject: Re: Query from within a cfscript
Here is the code (it's supposed to log to a table):
CFSCRIPT
function CSLog
No, I'm basing my code from this article:
http://www.macromedia.com/devnet/mx/coldfusion/extreme/cftags_cfscript.html
The sample code in the article seems to call a CFQuery from within a CFSCRIPT block:
CFSCRIPT
SQLString = Select * From LoginInfo where
UserID='BobZ' and Password = 'Ads10
a cfscript
No, I'm basing my code from this article:
http://www.macromedia.com/devnet/mx/coldfusion/extreme/cftags_cfscript.html
The sample code in the article seems to call a CFQuery from within a
CFSCRIPT block:
CFSCRIPT
SQLString = Select * From LoginInfo where
UserID='BobZ' and Password = 'Ads10
Hamlin [EMAIL PROTECTED] wrote:
No, I'm basing my code from this article:
http://www.macromedia.com/devnet/mx/coldfusion/extreme/cftags_cfscript.html
The sample code in the article seems to call a CFQuery from within a CFSCRIPT block:
CFSCRIPT
SQLString = Select * From LoginInfo where
I'm getting:
Variable CFQUERY is undefined.
Thanks,
Howie
- Original Message -
From: Adrian Lynch
To: CF-Talk
Sent: Wednesday, August 18, 2004 10:54 AM
Subject: RE: Query from within a cfscript
I didn't read the article, but it seems the dude has a cfquery function.
Sorry I deleted
Well, paint me stupid.
Thanks,
Howie
- Original Message -
From: Greg Stewart
To: CF-Talk
Sent: Wednesday, August 18, 2004 10:53 AM
Subject: Re: Query from within a cfscript
True but you still need to cerate a function called cfquery, here is
the code from the article:
cffunction
I have to agree with Dave...
Beside requiring changes to existing code, many of the tags in CFML
are implemented as regular CFML custom tags -- they're in one of the
directories in your cfmx installation, although I don't remember which
offhand. Which means implementing the cfsetting version=5.0
I agree with all that you say.
But what is the alternative?
Running multiple versions of CF?
if MM or NA wants to move the CF install base to their latest versions,
then providing total backward compatibility will forever restrict the
implementation to the mistakes and limitations of past
I agree with all that you say.
But what is the alternative?
Running multiple versions of CF?
if MM or NA wants to move the CF install base to their latest versions,
then providing total backward compatibility will forever restrict the
implementation to the mistakes and limitations of
I feel as if I should jump back into the conversation again.I did ask a loaded question regarding if MM is going to continue with CFscript in the future.I am sorry for opening up a can of worms.
As for the things not available in cfscript (i.e. cfabort, cfinclude, cflocate, etc.), there are way
...However.. you cannot manipuate
the
the returned array. Try increasing the size of the array.
Joe Eugene
-Original Message-
From: Dave Carabetta [mailto:[EMAIL PROTECTED]
Sent: Saturday, August 07, 2004 12:56 PM
To: CF-Talk
Subject: Re: Can the following be written in cfscript?
On Sat, 7 Aug
: Can the following be written in cfscript?
and cfml list loop is even more efficient than array...
Why is a list loop faster than an array loop?
http://www.rewindlife.com/archives/56.cfm
Sam
-Original Message-
From: S. Isaac Dealey [mailto:[EMAIL PROTECTED]
Sent: Friday, August 06
knows.In the end it may be
absolutely true that Java Arrays give the most performance - in Java.But
in CF it may not be true.
Jim Davis
_
From: Joe Eugene [mailto:[EMAIL PROTECTED]
Sent: Saturday, August 07, 2004 10:59 AM
To: CF-Talk
Subject: RE: Can the following be written in cfscript
and cfml list loop is even more efficient than array...
WOW!... There must be something really wrong with the CFMX
Implementation of
Arrays.
That is completely backwards to Java Implementation. Bruce
Eckel's (Thinking
in Java)
compares the Collection Classes and i believe mentions...
Lastly it may also be that you're right.CF Arrays aren't
Java Arrays.
They're counted from 1, not zero.They're passed by value
not by reference
(which I wish would change).I'm not sure what's under
the covers to do
this conversion.I assume, at least for looping, that
it's such a small
I agree completely - the argument is always that you can't change something
so fundamental because you don't know how people've used it.
I applaud, mostly, MM's desire to remain as backwards compatible as
possible.Sometimes it's just awkward tho'.;^)
Jim Davis
If they changed the behavior of
On Sat, 7 Aug 2004 10:59:25 -0400, Joe Eugene [EMAIL PROTECTED] wrote:
and cfml list loop is even more efficient than array...
WOW!... There must be something really wrong with the CFMX Implementation of
Arrays.
That is completely backwards to Java Implementation. Bruce Eckel's (Thinking
in
I agree completely - the argument is always that you can't
change something
so fundamental because you don't know how people've used
it.
I applaud, mostly, MM's desire to remain as backwards
compatible as
possible.Sometimes it's just awkward tho'.;^)
Yea... I often wish they were passed
.
On reflection, though this is exactly the way that they added scripting
with cfscript.../cfscript
So, they could implement compatibility with tags the user could
migrate an old app by simply adding the compatibility declaratives to
Application.cfm onRequestEnd.cfm.
Yea... I often wish
Good points. It would be very cool to see this in a future release;
maybe NewAtlanta will offer it first, putting the pressure on MM. :-)
Michael T. Tangorre
One way this has been done, historically, with other products, is to
support both new implementations and prior implementations with
Big question...
I've been writing a lot in cfscript lately.Seems easier a lot of the time, especially when writing long logic blocks and it can be a lot easier to read.Is MM going to do away with cfscript or should I write more in CFML.
[Todays Threads]
[This Message]
[Subscription]
[Fast
On Sat, 07 Aug 2004 17:44:54 -0400, Peter Farrell
[EMAIL PROTECTED] wrote:
Big question...
I've been writing a lot in cfscript lately.Seems easier a lot of the time, especially when writing long logic blocks and it can be a lot easier to read.Is MM going to do away with cfscript or should I
I'm not sure why you'd ask the question.What have you heard to make you
worry?
CFSCRIPT appeared in CF 4.x - it's newer than CFML and a core part of the
language.They really couldn't get rid of it at all easily.
That being said the other side of the coin is also true: it doesn't appear
In a way, that is odd:
1) cfscript resembles is based on _javascript_
2) so is Flash ActionScript
3) both cfml and ActionScript interface _javascript_ contained in html
You would think it would benefit developers using MM products to have a
common scripting language.
It has always bothered me
that they
added scripting with cfscript.../cfscript
Say what? cfscript has no attributes...
http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/tags-a31.htm#wp
1103056
s. isaac dealey954.927.5117
new epoch : isn't it time for a change?
add features without fixtures with
the onTap open
I'm just demonstrating that often when people say this is faster
than that it's not the primitive thing they're talking about their
implementation of it: even in simple testing code can often be
optimized.
More importantly, though, most of the which is faster stuff is
practically useless.
In a way, that is odd:
1) cfscript resembles is based on _javascript_
2) so is Flash ActionScript
3) both cfml and ActionScript interface _javascript_ contained in html
You would think it would benefit developers using MM products to
have a common scripting language.
It has always
I've been writing a lot in cfscript lately. Seems easier a lot of the
time, especially when writing long logic blocks and it can be a lot
easier to read. Is MM going to do away with cfscript or should I write
more in CFML.
I wouldn't worry about CFSCRIPT going away - the CF development team
I only meant that they added a new feature by including it within tags
-- that are, essentially, compiler directives.
Dick
On Aug 7, 2004, at 5:40 PM, S. Isaac Dealey wrote:
On reflection, though this is exactly the way that they
added scripting with cfscript.../cfscript
Say what? cfscript
with cfscript.../cfscript
I don't think they're comparable at all. CFSCRIPT was simply a brand new
tag. Pages without that tag would work on new versions of CF just as they
would on prior versions.
So, they could implement compatibility with tags the user could
migrate an old app by simply adding
That being said the other side of the coin is also true:
it doesn't appear
as if they're particularly anxious to add to CFSCRIPT,
either.;^)
Well yea, they created CFFUNCTION to be an end-run around the need to
support more featurees in cfscript... I understand why they took that
approach
Well if you included cfscript in a template executed on a CF3
server, the page would produce an error, so I guess I'm still unsure
how that equates to cfscript version=5.0 ... or your saying that
their addition of cfscript in version 4 was exactly that sort of
phenomenon... :-/ ... I'm confused
Sooner or later, backwards compatibility inhibits
progress.
Macromedia will need to address the BC issue or others
will
Unfortunately, we all have different definitions of
progress. Most of the
things that people have mentioned in this thread - NULL
values, strong
typing, etc - are
of the things that has made HTML so flexible is that i
every version just ignores tags that it doesn't understand (treats them
as comments) -- Brilliant!
Dick
On Aug 7, 2004, at 6:19 PM, S. Isaac Dealey wrote:
Well if you included cfscript in a template executed on a CF3
server, the page would
To me, backward compatibility means a new version runs prior version
code just like the prior version -- not that the new version additions
will run on a prior version.
I meant that new version of CF could accept prior version syntax,
assumptions. etc, by enclosing the target code within
Aw c'mon Dave -- be reasonable, application.cfm onRequestEnd.cf,
Even I can understand that.
Dick
On Aug 7, 2004, at 7:29 PM, Dave Watts wrote:
To me, backward compatibility means a new version runs prior version
code just like the prior version -- not that the new version
additions
If yes, how would it look. :)
cfif NOT isDefined(Form.Fieldnames)
cfset Fieldnames = CCType,CCNumber,CCID,CCMonth,CCYear,CCExpire
cfloop list=#Fieldnames# index=i
cfset Form[i] =
/cfloop
/cfif
Thanks Che
[Todays Threads]
[This Message]
[Subscription]
[Fast Unsubscribe]
[User
Che Vilnonis wrote:
If yes, how would it look. :)
cfif NOT isDefined(Form.Fieldnames)
cfset Fieldnames = CCType,CCNumber,CCID,CCMonth,CCYear,CCExpire
cfloop list=#Fieldnames# index=i
cfset Form[i] =
/cfloop
/cfif
if (NOT IsDefined(Form.Fieldnames) {
Fieldnames =
cfscript
if(not isDefined(form.fieldnames) {
fieldnames = CCType,CCNumber,CCID,CCMonth,CCYear,CCExpire;
}
for(i = 1; i lte listLen(fieldnames, ,); i = i + 1) {
form[listGetAt(fieldnames, i)] = ;
}
/cfscript
Steve
-Original Message-
From: Che Vilnonis [mailto:[EMAIL PROTECTED]
Sent
that's it...that darn listlen gets me every time!
-Original Message-
From: Jochem van Dieten [mailto:[EMAIL PROTECTED]
Sent: Friday, August 06, 2004 2:52 PM
To: CF-Talk
Subject: Re: Can the following be written in cfscript?
Che Vilnonis wrote:
If yes, how would it look. :)
cfif
cfscript
if(NOT isDefined(Form.Fieldnames)){
Fieldnames = CCType,CCNumber,CCID,CCMonth,CCYear,CCExpire;
for(i=1; i LT ListLen(FieldNames);i = i+1){
FORM[ListGetAt[i]] = ;
}
}
/cfscript
Or words to that effect.
MD
On Fri, 6 Aug 2004 14:45:27 -0400, Che Vilnonis [EMAIL PROTECTED
Jochem,
I expect that the cfscript version of that particular code is going to be
significantly slower than the cfml version.The cfml version is taking
advantage of a list loop with does a single tokenization of the list.The
cfscript version tokenizes the list twice in each iteration--once
Samuel R. Neff wrote:
I expect that the cfscript version of that particular code is going to be
significantly slower than the cfml version.The cfml version is taking
advantage of a list loop with does a single tokenization of the list.The
cfscript version tokenizes the list twice in each
If yes, how would it look. :)
cfif NOT isDefined(Form.Fieldnames)
cfset Fieldnames =
CCType,CCNumber,CCID,CCMonth,CCYear,CCExpire
cfloop list=#Fieldnames# index=i
cfset Form[i] =
/cfloop
/cfif
cfscript
if (not isdefined(form.fieldnames)) {
fnames =
listtoarray(CCType,CCNumber
Subject: Re: Can the following be written in cfscript?
Che Vilnonis wrote:
If yes, how would it look. :)
cfif NOT isDefined(Form.Fieldnames)
cfset Fieldnames =
CCType,CCNumber,CCID,CCMonth,CCYear,CCExpire
cfloop list=#Fieldnames# index=i
cfset Form[i] =
/cfloop
/cfif
if (NOT IsDefined
: Can the following be written in cfscript?
The array will be more efficient. (And personally I find that the
array usually involves fewer keystrokes as well.)
[Todays Threads]
[This Message]
[Subscription]
[Fast Unsubscribe]
[User Settings]
[Donations and Support]
or as an alternate for the listloop:
while (listlen(form.fieldnames) GT 0){
field = ListFirst(form.fieldnames);
form[field] = ;
form.fieldnames = ListRest(form.fieldnames);
}
Che Vilnonis wrote:
If yes, how would it look. :)
cfif NOT isDefined(Form.Fieldnames)
cfset Fieldnames =
Why tokenize the list twice per iteration when we can do it three times per
iteration?:-)
Sam
-Original Message-
From: Patricia Lee [mailto:[EMAIL PROTECTED]
Sent: Friday, August 06, 2004 4:09 PM
To: CF-Talk
Subject: Re: Can the following be written in cfscript
be written in cfscript?
or as an alternate for the listloop:
while (listlen(form.fieldnames) GT 0){
field = ListFirst(form.fieldnames);
form[field] = ;
form.fieldnames = ListRest(form.fieldnames);
}
[Todays Threads]
[This Message]
[Subscription]
[Fast Unsubscribe]
[User Settings]
[Donations
Yea, but I was only commenting on the cfscript version.
and cfml list loop is even more efficient than array...
Why is a list loop faster than an array loop?
http://www.rewindlife.com/archives/56.cfm
Sam
s. isaac dealey954.927.5117
new epoch : isn't it time for a change?
add features
If I assign a variable a value directly, eg cfset product_id = 101,
T can then read the variable #product_id# inside cfscript tags.
If I assign a variable a value via another variable, eg, cfset product_id =
getProduct.product_id it generates an error in cfscript when it tries to
read
501 - 600 of 1308 matches
Mail list logo