Changes

Jump to navigation Jump to search
77 bytes removed ,  12:56, 20 November 2012
Template typo
== How to pass over part of the source to an external program? ==
There are two ways: <{{cmd>|executesystemcommand</cmd> }} and<{{cmd>|installprogram</cmd>}}.* <{{cmd>|executesystemcommand</cmd> }} is equal to <{{cmd>|immediate</cmd><}}{{cmd>|write18</cmd> }} while* <{{cmd>|installprogram</cmd> }} defines a program in the tui file which is then run before the next execution of texexec.
I do not know what is the best source of their documenentation.
<{{cmd>|write</cmd> }} is explained in the texbookTeXbook, [[write18]] executes its argument on shell.
luatex will have a better model for executing commands on the shell, and some
of it is explained in the luatex manual. (But luatex is still pre-alpha, so
the interface can change).
<{{cmd>|installprogram</cmd> }} is not documented, you need to read [[source:core-uti.tex{{src|core-uti.tex]] }} and[[source:texutl.rb{{src|texutil.rb]] }} to understand how it works.
I found ConTeXt sources to be the best way to understand how these things are
working. See [[modules:t-lilypond|t-lilypond]], which checks if [[write18]] is enabled or not, and then
uses <{{cmd>|executesystemcommand</cmd> }} or <{{cmd>|installprogram</cmd>}}:
<texcode>
The module writes stuff to a temporary file, and then uses lilypond to get a ps/pdf which
is included back in the document. Another example is [[source:m-r.tex{{src|m-r.tex]] }} which writes
things to a temp file and runs them through R (a statistical program) and
types the output. It also shows how you can capture the contents of an
evironment to a temp file. The same idea is used in the [[modules:vim|t-vim]] module. Of
course, the ConTeXt sources have plenty of examples. There is also [[source:core-buf.tex{{src|core-buf.tex]]}}
where the buffer handling is implemented, and the sources related to metapost
handling, which are perhaps the best example of how to go back and forth
If you want to read the output verbatim to ConTeXt, you can use
<code>\{{cmd|typefile|{filename}</code>}}. If the external program outputs tex file,then you can use <code>\{{cmd|input|{filename}</code>}}.
== Modules which use write18 ==
* [[source:m-r.tex{{src|m-r.tex]]}}
* [[modules:t-lilypond|t-lilypond]]
* [[modules:vim|t-vim]]
* [[modules:gnuplot|t-gnuplot]]
* [[modules:filter|t-filter]]
[[Category:Inside ConTeXt]]

Navigation menu