# Writing a variable to file with its value, not its name [closed]

This is my first time ever posting a question about Mathematica anywhere, so please excuse my ignorance. I'm trying to save a ColorFunction to file, but can't get the variables to be written as numbers. No matter what I try, they get written as the variable names.

E.g., given white1, medgreen1 etc. having numerical values assigned by moving sliders inside a Manipulate[ ] routine (i.e., these variables are not hard-coded)...

  myCF1 = Function[z,
If[z < white1, RGBColor[1, 1, 1],
If[z < medgreen3, RGBColor[0, 0.75, 0],
If[z < darkgreen3, RGBColor[0, 0.4, 0],
If[z < yellow3, RGBColor[1, 1, 0],
If[z < orange3, RGBColor[1, 0.5, 0],
RGBColor[1, 0, 0] ]]]]]] ;

saveData[outFile_] := Module[{},
ptr = OpenWrite[outFile];
Write[ptr, myCF1];
Close[outFile];
];
saveData["test"];
myCF2 = Get["test"];
ArrayPlot[some2DdataSpanningZeroToOne, ColorFunction -> myCF2,
ColorFunctionScaling -> False]


Retrieving the file "test" results in an identical copy of the original ColorFunction code (which, of course, only works if white1, etc. have numerical values currently existing in memory). However, I want the original real numbers that resulted from my tweaking values in Manipulate[ ]--not just variable names. I've spent days trying everything that seemed obvious. Now, it makes sense to humbly seek help. How can I force variables to be written to file as their values, not their names? Many thanks.

## closed as off-topic by m_goldberg, Henrik Schumacher, LCarvalho, Sektor, gwrDec 5 '17 at 11:53

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – m_goldberg, Henrik Schumacher, LCarvalho, Sektor, gwr
If this question can be reworded to fit the rules in the help center, please edit the question.

• Use Save["test", myCF1] instead. – Carl Woll Dec 1 '17 at 22:41
• Thanks for responding, Carl. I tried Save, and it didn't quite work as needed, but you got my thinking moved out of the rut it was in. My problem is that my function myCF1 is "impenetrable" to the actual values of the various colors existing in memory. So, I tried rewriting it as – Wxguy Dec 4 '17 at 19:02
• @CarlWoll 'myCF1 = Function[z, If[z < #1, RGBColor[1, 1, 1], If[z < #2, RGBColor[0, 0.75, 0], If[z < #3, RGBColor[0, 0.4, 0], If[z < #4, RGBColor[1, 1, 0], If[z < #5, RGBColor[1, 0.5, 0], RGBColor[1, 0, 0] ]]]]]]&[white1, medgreen3, darkgreen3, yellow3, orange3] ;' and that now works. – Wxguy Dec 4 '17 at 19:11