9. September 2009 9:40 by Marc

FYI: Function returning Void kills Variables

9
Sep/09
1

I recently discovered some interesting behaviour in Coldfusion. If you ask for a result of a function in a variable and you set returntype void, the variable is destroyed and cant be found after this.

Example:

<cffunction name="getSomething" returntype="void">
 
     Do something here, like updating a database 
     or increasing a counter value
 
</cffunction>
 
<cfset VARIABLES.RecieveSomething = "">
 
<cfset VARIABLES.RecieveSomething= getSomeThing()>
 
<cfif IsDefined("VARIABLES.RecieveSomething")>
     still there
<cfelse>
     cant found this variable anymore
</cfif>

Returntype Void is kinda tricky, so use it well-considered.

Share and Enjoy:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • LinkedIn
  • MisterWong.DE
  • Netvibes
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati
  • Twitter
  • Yahoo! Bookmarks
  • LinkArena
  • Live
  • MySpace
  • Yahoo! Buzz
  • Yigg
  • blogmarks
  • Faves
  • FriendFeed
  • MisterWong