Yeah the problem with "var" in cfscript is you can only have it within the function() 
blocks

ie

<cfscript>
        function a() {
                var monkey = "spanked";
        }       

</cfscript>

This will work

But

If you want it outside:
<cfscript>
        var monkey = "spanked";
        function a() {

        }
</cfscript>

Will not.

The only way you can get this to work using the "var" style is to use <cfset var 
monkey = "spanked"> tags.

Scott Barnes 
Snr Developer
eCommerce Department
Tourism Queensland / Sunlover Holidays
[EMAIL PROTECTED]
ph: (07) 3535 5066 



-----Original Message-----
From: Joe Eugene [mailto:[EMAIL PROTECTED]
Sent: Wednesday, 26 March 2003 4:17 PM
To: [EMAIL PROTECTED]
Subject: [CFCDev] CFC variable scoping?



 Why is it that you have declare all you local var's before using
 a <cfscript> block.

 example
 <cfcomponent>
  <cffunction ...>
   <cfargument..>
   <cfscript>
        var myvar1="";
        var myvar2="";

  </cffuntion>
 </cfcompoent>

  The above gives an error and needs <cfset var myvar=""> grouped
  together before the <cfscript> block.
  In Java, you can declare method local vars anywhere (for(int
i=0;<=10;i++))
  in the body of the method. Why are CFC's acting differently?
  Can you declare static variables/methods in a CFC?

Thanks
Joe Eugene





----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev' 
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev'
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

Reply via email to