ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* \externalcommand?
@ 2007-01-04 21:10 cormullion
  2007-01-04 23:10 ` \externalcommand? Aditya Mahajan
  0 siblings, 1 reply; 6+ messages in thread
From: cormullion @ 2007-01-04 21:10 UTC (permalink / raw)


I think there's something in ConTeXt called \externalcommand. Can  
this be used to hand over a section of source text for processing by  
an external program during the ConTeXt-ing of a document? How does it  
work, exactly?

thanks again for help...

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: \externalcommand?
  2007-01-04 21:10 \externalcommand? cormullion
@ 2007-01-04 23:10 ` Aditya Mahajan
  2007-01-05  9:20   ` \externalcommand? Hans Hagen
  2007-01-05 22:56   ` \externalcommand? cormullion
  0 siblings, 2 replies; 6+ messages in thread
From: Aditya Mahajan @ 2007-01-04 23:10 UTC (permalink / raw)


On Thu, 4 Jan 2007, cormullion@mac.com wrote:

> I think there's something in ConTeXt called \externalcommand. Can
> this be used to hand over a section of source text for processing by
> an external program during the ConTeXt-ing of a document? How does it
> work, exactly?

There are two ways, \executesystemcommand and \installprogram. 
\executesystemcommand is equal to \immediate\write18 while \installprogram 
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.

\write is explained in the texbook, \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).

\installprogram is not documented, you need to read cont-uti.tex and 
texutil.rb to understand how it works.

I found ConTeXt sources to be the best way to understand how these things 
are working. See t-lilypond, which checks if write18 is enabled or not, 
and then uses \executesystemcommand or \installprogram. 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 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. I copied this idea in the t-vim module. Of 
course, the ConTeXt sources have plenty of examples. There is also 
core-buf 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 between tex and an external program.

Perhaps the R module is easiest to understand. That method will work for 
most cases where you simply want to capture part of tex source and write 
it verbatim to a file, and then read the output back into tex.

Aditya

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: \externalcommand?
  2007-01-04 23:10 ` \externalcommand? Aditya Mahajan
@ 2007-01-05  9:20   ` Hans Hagen
  2007-01-06 22:23     ` \externalcommand? Aditya Mahajan
  2007-01-05 22:56   ` \externalcommand? cormullion
  1 sibling, 1 reply; 6+ messages in thread
From: Hans Hagen @ 2007-01-05  9:20 UTC (permalink / raw)


Aditya Mahajan wrote:
> On Thu, 4 Jan 2007, cormullion@mac.com wrote:
>
>   
>> I think there's something in ConTeXt called \externalcommand. Can
>> this be used to hand over a section of source text for processing by
>> an external program during the ConTeXt-ing of a document? How does it
>> work, exactly?
>>     
>
> There are two ways, \executesystemcommand and \installprogram. 
> ...
>   
good text for the wiki

Hans

-- 

-----------------------------------------------------------------
                                          Hans Hagen | PRAGMA ADE
              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
                                             | www.pragma-pod.nl
-----------------------------------------------------------------

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: \externalcommand?
  2007-01-04 23:10 ` \externalcommand? Aditya Mahajan
  2007-01-05  9:20   ` \externalcommand? Hans Hagen
@ 2007-01-05 22:56   ` cormullion
  2007-01-06  0:02     ` \externalcommand? Aditya Mahajan
  1 sibling, 1 reply; 6+ messages in thread
From: cormullion @ 2007-01-05 22:56 UTC (permalink / raw)


On 2007-01-04, at 23:10.0, Aditya Mahajan wrote:

> Perhaps the R module is easiest to understand. That method will  
> work for
> most cases where you simply want to capture part of tex source and  
> write
> it verbatim to a file, and then read the output back into tex.

I'm really grateful for your continuing help. Thanks - and I've got  
this working fairly easily. I'm trying to work out what ConTeXt does  
when it reads in the text that the external program writes to the  
tmp.out file... It might be that I have to output some TeX commands  
to the tmp.out file rather than just plain text. That will require  
one of the other methods, i think.

plenty to do this weekend! ;-)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: \externalcommand?
  2007-01-05 22:56   ` \externalcommand? cormullion
@ 2007-01-06  0:02     ` Aditya Mahajan
  0 siblings, 0 replies; 6+ messages in thread
From: Aditya Mahajan @ 2007-01-06  0:02 UTC (permalink / raw)


On Fri, 5 Jan 2007, cormullion@mac.com wrote:

> On 2007-01-04, at 23:10.0, Aditya Mahajan wrote:
> 
> > Perhaps the R module is easiest to understand. That method will 
> > work for
> > most cases where you simply want to capture part of tex source and 
> > write
> > it verbatim to a file, and then read the output back into tex.
> 
> I'm really grateful for your continuing help. Thanks - and I've got 
> this working fairly easily. I'm trying to work out what ConTeXt does 
> when it reads in the text that the external program writes to the 
> tmp.out file...

basically \input reads a file and treats the material as if it were 
written in the tex file.

> It might be that I have to output some TeX commands to the tmp.out 
> file rather than just plain text.

That is what we do in t-vim module. The 2context.vim script writes a 
file that tex can understand.

>That will require one of the other methods, i think.

Another option is \typefile{tmp.out} which will display the file 
verbatim, or \typevimfile[syntax=txt]{tmp.out} using txt.vim from
http://www.vim.org/scripts/script.php?script_id=1532


Aditya

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: \externalcommand?
  2007-01-05  9:20   ` \externalcommand? Hans Hagen
@ 2007-01-06 22:23     ` Aditya Mahajan
  0 siblings, 0 replies; 6+ messages in thread
From: Aditya Mahajan @ 2007-01-06 22:23 UTC (permalink / raw)


On Fri, 5 Jan 2007, Hans Hagen wrote:

> Aditya Mahajan wrote:
> > On Thu, 4 Jan 2007, cormullion@mac.com wrote:
> >
> > 
> >> I think there's something in ConTeXt called \externalcommand. Can
> >> this be used to hand over a section of source text for processing by
> >> an external program during the ConTeXt-ing of a document? How does it
> >> work, exactly?
> >> 
> >
> > There are two ways, \executesystemcommand and \installprogram. 
> > ...
> > 
> good text for the wiki
> 
Added: http://wiki.contextgarden.net/Executesystemcommand

Aditya

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-01-06 22:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-04 21:10 \externalcommand? cormullion
2007-01-04 23:10 ` \externalcommand? Aditya Mahajan
2007-01-05  9:20   ` \externalcommand? Hans Hagen
2007-01-06 22:23     ` \externalcommand? Aditya Mahajan
2007-01-05 22:56   ` \externalcommand? cormullion
2007-01-06  0:02     ` \externalcommand? Aditya Mahajan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).