5.3. Scripting

Traditional literate programming tools have two conceptual processes: weaving (a document) and tangling (a code file) which separate out interleaved document and code sections (respectively).

Interscript has a third kind of section, the script section. In case you're wondering what script sections look like, well, you've already used them. All those lines starting with @ are just executable python script. They aren't really special magical commands, just function calls to predefined python functions.

You can write any python script you like in a script section. On-the-fly interscript for test 7 follows.

Start interscript section from tutorial.pak
   339: @name = 'John Skaller'
   340: @print 'Hello',name
   341: @print 'Running Python',sys.version
   342: @head(1,'Hello World from '+name)
   343: This is a scripting test.
   344: @weave('Written by '+name+'.')
End interscript section from tutorial.pak
Test output at ../tests/output/test_7.html. Logfile at ../tests/output/test_7.log.

Notice you don't have to import sys: it is already imported, because it is used in Interscript. [Add list of imported modules here]

You will also notice the

  @weave(text)
command, which weaves its argument: use this when you want to calculate text, as in the example. For more information on the weave command, see Unknown Label:weave command.

You should be careful with this feature. It is immensely powerful! You can use it to test programs, and to extend Interscript for you needs in a particular document -- without changing the actual source code for Interscript. See http://www.python.org to find out more about python.
5.3.1. Long script sections
5.3.2. Very Long script sections