Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I'm continuing to experiment with the SymbolicC` package, and it's crucial to be able to inspect the generated code in order to do, well, anything useful with it. The ToCCodeString makes this possible, but as far as I can tell, produces code with sensible line breaks but no indentation. Reading unindented code is sort of possible, but not at all fun. Is there an option to turn indentation on?

Right now, I've set things up so I can use the "Artistic Style" package for this purpose, and while it looks like a pretty nice program, relying on it means one more dependency on top of Mathematica and Visual Studio.

UPDATE to add: I'm interested in inspecting code that I generate programmatically, and developing the program to do the generation interactively in a notebook. I'd prefer not to have to take manual steps like using ToCCodeString to generate the string, and then copy'n'paste it to Visual Studio to inspect it unless I really have to.

share|improve this question
    
Does this msdn suit your purposes? –  rcollyer Nov 25 '13 at 15:12
4  
ToCCodeString has the "Indent" option, which defaults to None. Set it to the number of tabs you want for an indentation, and you should be fine. –  Leonid Shifrin Nov 25 '13 at 15:36
    
@LeonidShifrin I can't upvote that and possibly accept it unless you post it as an answer, not a comment. :) –  Pillsy Nov 25 '13 at 15:46
    
All right, done :) –  Leonid Shifrin Nov 25 '13 at 16:11

1 Answer 1

up vote 10 down vote accepted

ToCCodeString has the "Indent" option, which defaults to None. Set it to the number of tabs you want for an indentation, and you should be fine.

share|improve this answer

Your Answer

 
discard

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

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