From: Aditya Mahajan <adityam@umich.edu>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: mkiv: append to buffer
Date: Sat, 18 Dec 2010 11:52:48 -0500 (EST) [thread overview]
Message-ID: <alpine.LNX.2.01.1012181146180.16465@ybpnyubfg.ybpnyqbznva> (raw)
In-Reply-To: <web-6054490@be2.uni-bonn.de>
On Sat, 18 Dec 2010, Thomas Schmitz wrote:
> i guess this is easy, but I can't find an example to help
> me: I want to write a macro that will collect one of its
> arguments in a buffer and then collect the other argument in a buffer.
> Difficult to make a minimal example since I don't know how to do this, so
> here is some pseudo-code; this is what I want to achieve:
>
> \definebuffer[MyBuffer]
>
> \def\MyGreatMacro#1#2#3%
> {\item[#1] #2 \par
> \appendtobuffer{MyBuffer}{\in[#1] #3}}
>
> \starttext
> \startitemize
> \MyGreatMacro{1}{aa}{AA}
> \MyGreatMacro{2}{bb}{BB}
> \stopitemize
>
> \page
> \getbuffer[MyBuffer]
> \resetbuffer[MyBuffer] % so I can reuse the buffer
> \stoptext
>
> What I want to do with this is typeset exercises for my students, with an
> itemization for problems and solutions which use the same numbering. In real
> life, this will involve xml, but I will try and figure that out myself once I
> know how to use buffers...
>
> It looks like buffers.collectcontent should be able to do this, but I can't
> figure out how to use it. Any pointers? Thanks a lot!
I am not sure what you want to do, and why you want to use buffers. Wont a
simple token list work?
% Define a token list
\newtoks\mytoks
% Append to a token list
\appendtoks \in[#1] #3 \to\mytoks
% Recall a token list
\the\mytoks
% Reset a token list
\mytoks\emptytoks
For repeating question and answers, there is also blocks.
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
___________________________________________________________________________________
next prev parent reply other threads:[~2010-12-18 16:52 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-18 15:51 Thomas Schmitz
2010-12-18 16:52 ` Aditya Mahajan [this message]
2010-12-18 18:35 ` Wolfgang Schuster
2010-12-19 11:28 ` Thomas Schmitz
2010-12-19 12:21 ` Peter Münster
2010-12-19 12:47 ` Thomas Schmitz
2010-12-19 14:19 ` Thomas Schmitz
2010-12-20 7:11 ` Peter Münster
2010-12-19 21:30 ` Hans Hagen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.LNX.2.01.1012181146180.16465@ybpnyubfg.ybpnyqbznva \
--to=adityam@umich.edu \
--cc=ntg-context@ntg.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).