Am 03.03.2009 um 12:23 schrieb Hans Hagen:

A ConTeXt version of the filecontents for LaTeX would be handy in such cases.

i have no clue what this means

Thomas was unable to show his problem with a buffer, the filecontents
environment is like a buffer but writes the content to a file with
a given name, e.g.

<test.tex>
\begin{filecontentents}{example.xml}
<?xml version="1.0" encoding="utf-8"?>
<auth>
<section><content>Hello &lt;</content></section>
</auth>
\end{filecontents}

...

\starttext
\xmlprocess{main}{example.xml}{}
\stoptext
</test.tex>

Everything between \begin/end{filecontents} is written to the file example.xml.

This is handy for example given on the list because attatchments are a problem in the mail archive and you have to create only one tex file for the example.

Here is a example but it works only on MkII.

\unprotect

\def\startfilecontents
  {\bgroup
   \protectbuffersfalse
   \dosingleargument\dostartfilecontents}

\def\dostartfilecontents[#1]%
  {\beforesplitstring#1\at.\to\filename
   \aftersplitstring #1\at.\to\extension
   \let\f!temporaryextension\extension
   \dostartbuffer[\filename][startfilecontents][stopfilecontents]}

\def\stopfilecontents
  {\doifdefined{savebuffer}{\savebuffer[\filename]}\egroup}

\protect

\startfilecontents[a1.txt]
1 5
2 4
3 8
4 9
8 8
\stopfilecontents

\starttext
\readfile{a1.txt}{}{}
\stoptext

Wolfgang

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to