CFLib.org – Common Function Library Project

WDDXFileWrite(file, var)

Last updated October 15, 2002
Download UDF

author

Nathan Dintenfass                                 Nathan Dintenfass

Version: 2 | Requires: ColdFusion MX | Library: CFMLLib

 
Rated 1 time(s). Average Rating: 5.0

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

Shawn Porter Shawn Porter added
DeMoronize
3 hour(s) ago

Chris Carey Chris Carey added
readPropertiesFi...
1 day(s) ago

Randy Johnson Randy Johnson added
lastDayofWeek
3 day(s) ago

Frank Marion Frank Marion added
sitemapPing
7 day(s) ago

Top Rated

James Sleeman                                     QuickSort
Rated 5.0, 3 time(s)

Barney Boisvert indentXml
Rated 5.0, 3 time(s)

Nathan Dintenfass                                 queryColumnsToSt...
Rated 5.0, 3 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 3 time(s)

Created by Raymond Camden / Design by Justin Johnson