Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have one problem about printing data in Mathematica. If the line so long for example

S=11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111

I want to print S in form first five empty spaces, then to put "#" then 66 spaces of S, then enter, next order again the same. This form must be in WordPad open like here

 "5 spaces empty"#1111111111"(66times)"111111
 "5 spaces empty"#1111111111"(66times)"111111
  .....

Best wishes,

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

You can use the following code:

In[58]:=
S=1111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111111111111111111111111111111111111111111111111111111111\
1111111111111111111111111111111111111111111111111111;
StringPartition[s_,l_]:=Table[StringTake[s,{i,Min[i+l-1, 
StringLength[s]]}],{i,1,StringLength[s],l}];
fmts=Map[("     #"<>#<>"\r")&,StringPartition[ToString[S],66]];
(* Unfortunately the web software is ruining the formatting of the output, deleting the extra spaces I placed before the #, etc. *)
(* But if you fix all the things this web software broke when I pasted your result and then run this and check the output carefully you should see it is correct *)
FullForm[fmts]

Out[61]//FullForm=
List[
"     #111111111111111111111111111111111111111111111111111111111111111111\r",
"     #111111111111111111111111111111111111111111111111111111111111111111\r",
"     #111111111111111111111111111111111111111111111111111111111111111111\r",
"     #111111111111111111111111111111111111111111111111111111111111111111\r",
"     #111111111111111111111111111111111111111111111111111111111111111111\r",
"     #11111111111111111111111111111111\r"
]
share|improve this answer
    
Thank you it is working. Just to check something little bit and I will write you. –  Pipe Dec 30 '11 at 20:40
add comment

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.