Guest User

Untitled

a guest
Mar 23rd, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. ClearAll[myPrint];
  2. myPrint[exp_] := Module[{dir, fns, nb},
  3. dir = NotebookDirectory[];
  4. fns = FileNames[FileNameJoin[{dir, "myMessagesTemp.nb"}]];
  5.  
  6. If[fns === {},
  7. nb = CreateNotebook[];
  8. NotebookSave[nb, FileNameJoin[{dir, "myMessagesTemp.nb"}]],
  9. nb = NotebookOpen[fns[[1]]]
  10. ];
  11.  
  12. NotebookWrite[nb, Cell[exp, "Output"]]
  13. ]
  14.  
  15. Module[{},
  16. myPrint["Hello World"];
  17. myPrint["Hello Again"];
  18. Do[myPrint[n], {n, 4}]
  19. Do[myPrint[ToString[n]], {n, 4}]
  20. myPrint[x^2];
  21. ]
Add Comment
Please, Sign In to add comment