diff --git a/src/postProcessing/functionObjects/utilities/codedFunctionObject/codedFunctionObject.C b/src/postProcessing/functionObjects/utilities/codedFunctionObject/codedFunctionObject.C
index 7745c7e308bbd2f13519d060950e4fa46b39921f..81cb1d9b23b651bd57bd5b21edbba62e56309770 100644
--- a/src/postProcessing/functionObjects/utilities/codedFunctionObject/codedFunctionObject.C
+++ b/src/postProcessing/functionObjects/utilities/codedFunctionObject/codedFunctionObject.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
+    \\  /    A nd           | Copyright (C) 2011-2012 OpenFOAM Foundation
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -63,6 +63,7 @@ void Foam::codedFunctionObject::prepare
     dynCode.setFilterVariable("codeRead", codeRead_);
     dynCode.setFilterVariable("codeExecute", codeExecute_);
     dynCode.setFilterVariable("codeEnd", codeEnd_);
+    dynCode.setFilterVariable("codeData", codeData_);
     //dynCode.setFilterVariable("codeWrite", codeWrite_);
 
     // compile filtered C template
@@ -191,6 +192,24 @@ bool Foam::codedFunctionObject::read(const dictionary& dict)
 {
     dict.lookup("redirectType") >> redirectType_;
 
+    const entry* dataPtr = dict.lookupEntryPtr
+    (
+        "codeData",
+        false,
+        false
+    );
+    if (dataPtr)
+    {
+        codeData_ = stringOps::trim(dataPtr->stream());
+        stringOps::inplaceExpand(codeData_, dict);
+        dynamicCodeContext::addLineDirective
+        (
+            codeData_,
+            dataPtr->startLineNumber(),
+            dict.name()
+        );
+    }
+
     const entry* readPtr = dict.lookupEntryPtr
     (
         "codeRead",
@@ -233,7 +252,7 @@ bool Foam::codedFunctionObject::read(const dictionary& dict)
         false,
         false
     );
-    if (execPtr)
+    if (endPtr)
     {
         codeEnd_ = stringOps::trim(endPtr->stream());
         stringOps::inplaceExpand(codeEnd_, dict);
diff --git a/src/postProcessing/functionObjects/utilities/codedFunctionObject/codedFunctionObject.H b/src/postProcessing/functionObjects/utilities/codedFunctionObject/codedFunctionObject.H
index 9f0659ac72dfe044391c7b7c4c59ea02acb1759a..52a202df54bd0dc4ebabe68028279141ee0f6cfb 100644
--- a/src/postProcessing/functionObjects/utilities/codedFunctionObject/codedFunctionObject.H
+++ b/src/postProcessing/functionObjects/utilities/codedFunctionObject/codedFunctionObject.H
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
+    \\  /    A nd           | Copyright (C) 2011-2012 OpenFOAM Foundation
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -64,6 +64,7 @@ protected:
 
         word redirectType_;
 
+        string codeData_;
         string codeRead_;
         string codeExecute_;
         string codeEnd_;