On Sun, 4 Mar 2012, Kip Warner wrote:

Hey list,

I'd like to include the output of a command. I am using the following to
define the command,

\def\BazaarRevision{\cldcontext{os.resultof"bzr revno | tr -d '\\n'"}}

and the following to use the output of the command,

\BazaarRevision

A concern I have is whether this command is executed multiple times
during the typesetting process when it need only be done once with the
result cached. If this is indeed the case,

Yes.

does anyone have any suggestions?

The cleaner way is to seperate the setup and use. For example:

\def\initilizebazaar
    {\ctxlua{context.setevalue(
              "usebazaarrevision",
               os.resultof"bzr revno | tr -d '\\n'")}}

\appendtoks \initilizebazaar \to \everystarttext

and then use can use \usebazaarrevision in the main text.

If you want to use the automagic way, you can define \BazaarRevision to redefined \BazaarRevision, for example:

\def\BazaarRevision
      {\ctxlua{context.setevalue(
                "BazaarRevision",
                 os.resultof"bzr revno | tr -d '\\n'")}%
       \BazaarRevision}


Aditya

___________________________________________________________________________________
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  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to