Sign up ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I try to interact with mathematica using MathLink for symbolic computations. By default it returns strings such as 2\012-1 + E\012-------\012 3\012 E if the input is Integrate[Exp[-x],{x,1,3}]. For better usability I would like it to print all output in InputForm which I could achieve by wrapping all input by a InputForm[] command (would this be bullet-proof for all possible input?). However it would be more elegant if I could define this once for all at the beginning of a session. Is there a way to do this? Furthermore the output seems to include the Out[#] labels which I know from Notebook files. I would prefer to suppress it as well. Obviously I could do it by cutting it manually from the returned string but there might be an elegant solution as well.

share|improve this question
You could use $Post or you could transfer structured expressions through MathLink instead of strings. Transferring the expressions directly instead of their string-representation is bullet-proof. What are you using the output for? Is the consumer a human reader or a computer program? – Szabolcs Feb 8 '14 at 15:51
It turns out that defining $Post produces two lines of output for each command like ` a=1 Out[7]//InputForm= 1 Out[8]//InputForm= , which I would want to avoid. I wrote a little frontend with MathLink in C starting from the publicly available frontend.c` which pipes the output into vim, so the consumer is me, but I prefer the InputForm over pseudo math equations in ascii-art. – highsciguy Feb 8 '14 at 16:19
So I would probably append // InputForm to each block of input, but the input might consist of multiple lines and several commands. To parse it beforehand would be too difficult. To cut the produced Out[1]//InputForm= by hand would not be elegant, but surely possible. – highsciguy Feb 8 '14 at 16:25
For the first part it helps to call once SetOptions["stdout", FormatType->InputForm]. But Out[#] still gets printed. – highsciguy Feb 8 '14 at 17:49

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.