CFLib.org – Common Function Library Project

WDDXFileWrite(file, var)

Last updated October 15, 2002

author

Nathan Dintenfass

Version: 2 | Requires: CF6 | Library: CFMLLib

Description:
Ever get annoyed at the couple of lines you are always writing to store and retrieve WDDX in flat files? Then this is the UDF for you. Also see it's sister UDF WDDXFileRead().

Return Values:
Does not return a value.

Example:

<cfscript>
    hello = structNew();
    hello.foo.bar = 2;
    hello.thing = "a string";
//    wddxfileWrite(expandPath("test.wddx"),hello);
//    stuff = WDDXFileRead(expandPath("test.wddx"));
</cfscript>
<!---
<cfdump var="#stuff#">
--->

Parameters:

Name Description Required
file The file to write to. Yes
var The value to serialize. Yes

Full UDF Source:

<!---
 Write a flat file containing a WDDX packet of any CF variable
 Updated for CFMX var scope syntax.
 
 @param file      The file to write to. (Required)
 @param var      The value to serialize. (Required)
 @return Does not return a value. 
 @author Nathan Dintenfass (nathan@changemedia.com) 
 @version 2, October 15, 2002 
--->
<cffunction name="WDDXFileWrite" output="no" returnType="void">
    <cfargument name="file" required="yes">
    <cfargument name="var" required="yes">
    
    <cfset var tempPacket = "">
    
    <!--- serialize --->
    <cfwddx action="cfml2wddx" input="#var#" output="tempPacket">
    <!--- write the file --->
    <cffile action="write" file="#file#" output="#tempPacket#">
</cffunction>

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson