3
$\begingroup$

If I do

Format[$hello, StandardForm] := "world"

then

Put[HoldComplete[Format[$hello, StandardForm]], "file.m"]

or

Export["file.m", HoldComplete[Format[$hello, StandardForm]]]

file.m will contain

HoldComplete["\"world\""]

How do I get literally

HoldComplete[Format[$hello, StandardForm]]

in the exported file?

$\endgroup$

2 Answers 2

6
$\begingroup$
Block[{Format},
   Put[
      HoldComplete[Format[$hello, StandardForm]],
      "file.m"
   ]
]

FilePrint @ "file.m"
test = Get @ "file.m"
FullForm[test]

enter image description here

$\endgroup$
0
$\begingroup$
Export["file.m", FullForm@HoldComplete[Format[$hello, StandardForm]], "String"]

works, but all operators will be eliminated because of FullForm:

FullForm@HoldComplete[Format[$hello, StandardForm]*2]

HoldComplete[Times[Format[$hello, StandardForm], 2]]

$\endgroup$
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.