Tuesday, December 12, 2006

CFDUMP inside CFCSCRIPT

It is true, you can not call CF tags from inside CFSCRIPT. However, you can call a function that can run CF tags. Using this knowledge you can to a wealth of things. Most importantly you can do a CFDUMP inside CFSCRIPT. Here is an example of how to call a function that does a CFDUMP from inside CFSCRIPT:


<CFSCRIPT>
sampleArray = Arraynew(1);

for (z = 1; z LT 100; z=z+1){
sampleArray[z] = z;
if (z EQ 50){
writeoutput(dumpIt(sampleArray));
}
}
</CFSCRIPT>
<CFFUNCTION NAME="dumpIt">
<CFARGUMENT NAME="theData" REQUIRED="YES" TYPE="ANY">

<CFSAVECONTENT VARIABLE="theDump">
<CFDUMP VAR="theData">
</CFSAVECONTENT>
<CFRETURN theDump>
</CFFUNCTION>

1 comment:

Anonymous said...

This is very cool.