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>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson