tags:

views:

1029

answers:

3

Hi

In order to debug I would like to dump certain variables on to my web page. How to do that from inside a cfscript tag?

I tried the following but it ain't work-

<cfscript>
...
<cfif cgi.REMOTE_ADDR eq "IP">
<cfdump var="#var1#"><br/>
</cfif>
...
</cfscript>

Any clues on what can be done?

cheers

+8  A: 

You can't do it directly like that. You can, however, use the dump() UDF found at CFLIB ( http://cflib.org/udf/Dump ). There's a whole library of UDFs there that mimic CF tags that don't have direct CFSCRIPT equivalents.

Al Everett
+1  A: 

It would be fairly easy to write your own too. You just define a function in cfml rather than cfscript. You can use this to do cfaborts and cfloops as well.

Something like this (Off the top of my head...not executed).

<CFFUNCTION NAME="MyDump">
    <CFARGUMENT NAME="OBJ" Required="TRUE">
    <CFDUMP VAR="#Obj#">
</CFFUNCTION>
<CFSCRIPT>
  if(cgi.REMOTE_ADDR eq "IP"){
    MyDump(Var1);
  }
</CFSCRIPT>
Tom Hubbard
+1  A: 
<cffunction name="setAbort" access="private" returntype="void" output="false">
 <cfdump var="#arguments#"/><cfabort>
</cffunction>
Derek