Difference between revisions of "Command/grabbufferdata"

From Wiki
Jump to navigation Jump to search
(Created page with "{{Reference |name={{subst:SUBPAGENAME}} |attributes= }} == Syntax == <table cellspacing="4" cellpadding="2" class="cmd"> <tr> <td colspan="2" class="cmd...")
 
Line 32: Line 32:
 
== Example ==
 
== Example ==
 
<context source=yes mode=mkiv>
 
<context source=yes mode=mkiv>
\grabbufferdata[mybuffer][thisisthestart][thisistheend]
+
\setuppapersize[A6]
 +
\define\thisisthestart%
 +
  {\grabbufferdata[mybuffer][thisisthestart][thisistheend]}
 +
 
 +
% If you want to perform some action when the buffer ends
 +
% \let\thisistheend{...}
 +
 
 
\thisisthestart
 
\thisisthestart
My friend, you would not tell with such high zest
+
Bent double, like old beggars under sacks,
To children ardent for some desparate glory,
+
Knock-kneed, coughing like hags, we cursed through sludge,
The old Lie: Dulce et decorum est  
+
Till on the haunting flares we turned our backs
Pro patria mori.
+
And towards our distant rest began to trudge.
 +
\rightaligned{--- Wilfred Owen, excerpt from {\it Dulce et decorum est}}
 
\thisistheend
 
\thisistheend
  
\typebuffer[mybuffer]
+
\obeylines
 +
\getbuffer[mybuffer]
 
</context>
 
</context>
  

Revision as of 16:35, 15 December 2012

\grabbufferdata

Syntax

\grabbufferdata[...][...][...]
[...] name of the buffer to store the text
[...] string where the buffer contents start
[...] string where the buffer contents end

Description

This is a slightly low-level command to grab user input and store it in a buffer. It is different from \startbuffer[X]..\stopbuffer because it allows one to use custom start and end strings, instead of \startbuffer...\stopbuffer

Example

\setuppapersize[A6]
\define\thisisthestart%
  {\grabbufferdata[mybuffer][thisisthestart][thisistheend]}

% If you want to perform some action when the buffer ends
% \let\thisistheend{...}

\thisisthestart
Bent double, like old beggars under sacks,
Knock-kneed, coughing like hags, we cursed through sludge,
Till on the haunting flares we turned our backs
And towards our distant rest began to trudge.
\rightaligned{--- Wilfred Owen, excerpt from {\it Dulce et decorum est}}
\thisistheend

\obeylines
\getbuffer[mybuffer]

See also

Help from ConTeXt-Mailinglist/Forum

All issues with: