Link to home
Start Free TrialLog in
Avatar of tbaum
tbaum

asked on

How do I undefine a variable in CF 5.0?

How can I completely remove/annihilate/undefine a defined variable that would cause it to then fail an 'IsDefined()' test?

Example:

<cfset Application.TempVar = "test">

<!--- do what? to cause this if test to fail? --->

<cfif IsDefined( "Application.TempVar" )>
   <cfoutput>OK</cfoutput>
<cfelse>
   <!--- want to wind up HERE --->
   <cfoutput>but I thought it existed!</cfoutput>
</cfif>

Remember, CF5! Thanks!
ASKER CERTIFIED SOLUTION
Avatar of mosphat
mosphat

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kkhipple
kkhipple

my little workaround to that problem is to check if the variable exists and to check it a value for it exists


<CFIF IsDefined( "Application.TempVar" )> AND Application.TempVar NEQ "">



or something to that affect
Avatar of tbaum

ASKER

mosphat, GOOD ANSWER, now do me one better...

You will get the points, now for the bonus round...

That will work find for Application and Session vars, but what about just plan-old local vars?  How would you go about destroying them?

Thanks.
Like I said: even if you don't define a scope, it ends up in the variables scope.

This variable is actually set in the variables scope:
<cfset plain_old_local_var = "test">

So you can delete it like this:
<cfset structDelete(variables, "plain_old_local_var")>