1

It is possible to automatically save a notebook as a Package (see https://mathematica.stackexchange.com/a/1370/5340). The generated package file only contains the cells marked as Code.

This has the advantage that you can exploit the notebook formatting capabilities (such as display fractions), which are converted to plain text in the generated package.

How can I do the same with a Wolfram Script?

a06e
  • 11,327
  • 4
  • 48
  • 108
  • 1
    You can edit a wls file with the front end and if you do, you can include other cells (e.g. text). You can create one using File -> New -> Script. – Szabolcs Apr 04 '18 at 16:29
  • @Szabolcs The code cells (which are the ones executed) containing display fractions (for example), are replaced with inline fractions when I save the script and reload. This doesn't happen with packages, if I program in the notebook and then do the Autogenerate package setting. I am trying to achieve the same thing with scripts. – a06e Apr 04 '18 at 16:49
  • OK, I see. I don't really use wls files, but is there anything special about the extension? Can you just run any .m file with wolframscript? – Szabolcs Apr 04 '18 at 17:55
  • @Szabolcs I don't know. I guess that would answer my question. – a06e Apr 04 '18 at 18:30
  • @Szabolcs As far as I can tell, the only difference between .wls and .m is that the .wls has the shebang line #!/usr/bin/env wolframscript, and the .wls is executable by default. – a06e Apr 05 '18 at 12:14
  • 1
    How do you pragrammatically save a notebook as a script? It would be nice to have a wolframscript that reads all the definitions in a notebook – Fortsaint Jan 17 '19 at 17:47

0 Answers0