This is probably a simple-minded question, but I've tried many things that haven't worked. In the output below, how does one add a line break before "points=..."? It will also need to work in PutAppend.

Print["iter=", iter, "points=", points]
  • 1
    $\begingroup$ ..."\npoints="... $\endgroup$
    – Kuba
    May 16 '19 at 9:07
  • $\begingroup$ This works for Print but unfortunately not for PutAppend. $\endgroup$
    – Friasco
    May 16 '19 at 10:39
  • $\begingroup$ PutAppend["test", "this", "C:/temp/temp.txt"] $\endgroup$
    – Alan
    May 16 '19 at 12:54

Perhaps this will be close enough to what you want.

iter = 3;
points = {{0, 0}, {2, 6}, {0, 6}, {5, 7}};
tmp = StringTemplate["``=``"]
Do[Print[tmp[s, ToExpression@s]], {s, {"iter", "points"}}]
Do[PutAppend[tmp[s, ToExpression@s], "C:/temp/temp.txt"], {s, {"iter", "points"}}]
  • $\begingroup$ Thanks, that works. Sometimes I pine for the simplicity of Fortran-like I/O. $\endgroup$
    – Friasco
    May 17 '19 at 4:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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