I like to use the variant of ShowIt for debugging purpose in Mathematica defined here https://stackoverflow.com/a/8270643/884752. I was reading again the idea of rcollyer to use messages for some functions to turn them on or off here https://stackoverflow.com/a/4211700/884752. And I'm asking myself if it would be possible to do something similar for ShowIt, but I didn't manage to. Does someone have any idea ? Thanks
Asked
Active
Viewed 160 times
1 Answers
1
If I understand your intention:
debug::ShowIt = "`1`";
SetAttributes[System`ShowIt, HoldAll];
System`ShowIt[code__] := System`ShowIt[{code}];
System`ShowIt[code_] :=
With[{y = code},
Message[debug::ShowIt, HoldForm[code = y]];
y
];
In[5]:= ShowIt[2 + 2] During evaluation of In[5]:= debug::ShowIt: 2 + 2 = 4 Out[5]= 4 In[6]:= Off[debug::ShowIt] ShowIt[2 + 2] Out[7]= 4

Mr.Wizard
- 24,179
- 5
- 44
- 125
-
Thank you, this is what I wanted. I cannot convert the output of the debug message to an input format like I do for the original ShowIt. Is there a way to circumvent this? – faysou Jan 15 '12 at 11:27
-
@Faysal, I don't know. I'll make an attempt tomorrow. – Mr.Wizard Jan 15 '12 at 15:35