yerp pretty sure i read it was a bug and that you had to bite the bullet and use the variables.scope :)
Scott <[EMAIL PROTECTED]> wrote in message news:21900@cfaussie... > > > This email is to be read subject to the disclaimer below. > > > > <cfscript> > > var i = x = 0; > > </cfscript> > > I was always kind of wondering if this worked in CF, considering that in > lot of places they don't allow the assignment operator, like 'if(i=x)' > (which is legal in C/C++/Java AFAIK). > > Unfortunately you can't use var inside <cfscript> when you use <cffunction> > because the CFML parser throws an error. Basically it says that variable > declarations should come before any other tags -- which is correct, except > for the fact that the <cfscript> tag doesn't get compiled into java. > > So this wouldn't work: > <cffunction name="foo"> > <cfscript> > var i = 0; > <cfscript> > [ do stuff here ] > </cffunction> > > Should this be considered a bug? > > Viktor Radnai > Web Developer, National E-Commerce, Ernst & Young > Direct: +61 2 9248 4361 > > > > > "Scott Barnes" > <[EMAIL PROTECTED]> To: "CFAussie Mailing List" <[EMAIL PROTECTED]> > Sent by: cc: > [EMAIL PROTECTED] Subject: [cfaussie] Re: cfset + var inside <cffunction> > mon.com.au > > 16/01/2003 10:56 AM > Please respond to "CFAussie > Mailing List" > > > > > > FYI: Also, > > Instead of using the <CFSET> tags, use <CFSCRIPT> var x = 22 </cfscript>, > if > its just a once of cfset that yeah i guess cfset is aok, but if you have a > block of cfset vars, then use cfscript as its faster and more effecient.. > so > i've been told and read.. > > Also, would like some clarification, i read yesterday that if you do: > > <cfscript> > var i = x = 0; > </cfscript> > > if is faster (runtime wise) to do : > <cfscript> > var i = 0; > var x = 0; > </cfscript> > > Am i on crack? > > Scott > > <[EMAIL PROTECTED]> wrote in message news:21892@cfaussie... > > > > > > This email is to be read subject to the disclaimer below. > > > > > Or ever better you can actually call a function with cfset :D > > > > > <cfset doMyMonkeylove()> > > > > Yes, I've seen this somewhere in the docs, and been using it for a while. > > But the cool thing about being able to use the var keyword with <cfset> > is > > that now I could go around and implement every single CF tag as an > > user-defined function without having to worry about overwriting > variables. > > > > So no more hopping in and out of <cfscript> for things like <cfquery>, > > <cffile>, etc. Hooray... > > > > Anyone thought of / interested in doing something like that? > > > > Viktor Radnai > > Web Developer, National E-Commerce, Ernst & Young > > Direct: +61 2 9248 4361 > > > > > > > > > > "Scott Barnes" > > <[EMAIL PROTECTED]> To: > "CFAussie Mailing List" <[EMAIL PROTECTED]> > > Sent by: cc: > > [EMAIL PROTECTED] Subject: > [cfaussie] Re: cfset + var inside <cffunction> > > mon.com.au > > > > 16/01/2003 10:30 AM > > Please respond to "CFAussie > > Mailing List" > > > > > > > > > > > > > > > > <[EMAIL PROTECTED]> wrote in message news:21889@cfaussie... > > > > > > > > > This email is to be read subject to the disclaimer below. > > > > > > Hi all, > > > > > > I have just stumbled upon an useful feature of <cfset> so I thought I > > share > > > it with y'all. Someone might find it useful. > > > > > > It is possible to declare local variables using the 'var' keyword like > > this > > > (nothing new here): > > > function foo() { > > > var i=0; > > > [ do stuff ] > > > } > > > > > > Unfortunately I couldn't find anything in the CFMX documentation on how > > to > > > do the same thing using the <cffunction> tag. So, just as a wacky idea > I > > > tried using the syntax below: > > > <cffunction name="foo"> > > > <cfset var i=0> > > > [ do stuff ] > > > </cffunction> > > > > > > To my surprise it worked. > > > Is this a feature of CFMX or does it just work by accident? And if it > is > > a > > > feature, is it documented somewhere? > > > > > > Vik > > > --------------------- > > > Viktor Radnai > > > Web Developer, National E-Commerce, Ernst & Young > > > Direct: +61 2 9248 4361 > > > > > > > > > -------------------- > > > NOTICE - This communication contains information which is confidential > > and > > > the copyright of Ernst & Young or a third party. > > > > > > If you are not the intended recipient of this communication please > delete > > > and destroy all copies and telephone Ernst & Young on 1800 655 717 > > > immediately. If you are the intended recipient of this communication > you > > > should not copy, disclose or distribute this communication without the > > > authority of Ernst & Young. > > > > > > Any views expressed in this Communication are those of the individual > > > sender, except where the sender specifically states them to be the > views > > of > > > Ernst & Young. > > > > > > Except as required at law, Ernst & Young does not represent, warrant > > and/or > > > guarantee that the integrity of this communication has been maintained > > nor > > > that the communication is free of errors, virus, interception or > > > interference. > > > > > > Liability limited by the Accountants Scheme, approved under the > > > Professional Standards Act 1994 (NSW) > > > -------------------- > > > > > > > > > > > > > > > > > > > > > > > --- > > You are currently subscribed to cfaussie as: > > [EMAIL PROTECTED] > > To unsubscribe send a blank email to > > [EMAIL PROTECTED] > > > > MX Downunder AsiaPac DevCon - http://mxdu.com/ > > > > > > > > > > -------------------- > > NOTICE - This communication contains information which is confidential > and > > the copyright of Ernst & Young or a third party. > > > > If you are not the intended recipient of this communication please delete > > and destroy all copies and telephone Ernst & Young on 1800 655 717 > > immediately. If you are the intended recipient of this communication you > > should not copy, disclose or distribute this communication without the > > authority of Ernst & Young. > > > > Any views expressed in this Communication are those of the individual > > sender, except where the sender specifically states them to be the views > of > > Ernst & Young. > > > > Except as required at law, Ernst & Young does not represent, warrant > and/or > > guarantee that the integrity of this communication has been maintained > nor > > that the communication is free of errors, virus, interception or > > interference. > > > > Liability limited by the Accountants Scheme, approved under the > > Professional Standards Act 1994 (NSW) > > -------------------- > > > > > > > > > > > > > > > --- > You are currently subscribed to cfaussie as: > [EMAIL PROTECTED] > To unsubscribe send a blank email to > [EMAIL PROTECTED] > > MX Downunder AsiaPac DevCon - http://mxdu.com/ > > > > > -------------------- > NOTICE - This communication contains information which is confidential and > the copyright of Ernst & Young or a third party. > > If you are not the intended recipient of this communication please delete > and destroy all copies and telephone Ernst & Young on 1800 655 717 > immediately. If you are the intended recipient of this communication you > should not copy, disclose or distribute this communication without the > authority of Ernst & Young. > > Any views expressed in this Communication are those of the individual > sender, except where the sender specifically states them to be the views of > Ernst & Young. > > Except as required at law, Ernst & Young does not represent, warrant and/or > guarantee that the integrity of this communication has been maintained nor > that the communication is free of errors, virus, interception or > interference. > > Liability limited by the Accountants Scheme, approved under the > Professional Standards Act 1994 (NSW) > -------------------- > > > > > --- You are currently subscribed to cfaussie as: [email protected] To unsubscribe send a blank email to [EMAIL PROTECTED] MX Downunder AsiaPac DevCon - http://mxdu.com/
