%D \module
%D   [       file=core-buf,
%D        version=2000.01.05, 
%D          title=\CONTEXT\ Core Macros,
%D       subtitle=Buffers and Blockmoves,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA / Hans Hagen \& Ton Otten}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for 
%C details. 

% investigate etex's \readline and \scantokens 

\writestatus{loading}{Context Core Macros / Buffers and Blockmoves}

\startmessages  dutch  library: textblocks
  title: tekstblokken
      1: nieuwe versie, tweede run nodig
      2: wegschrijven blokken naar --
      3: inlezen blokken uit --
      4: er is een tweede run nodig
      5: -- niet verborgen
      6: -- verborgen en verwerkt
      7: -- verborgen
      8: -- gehandhaafd
      9: -- niet gehandhaafd
     10: -- geladen en verwerkt
     11: -- geladen en geplaatst
     12: -- overgeslagen
\stopmessages

\startmessages  english  library: textblocks
  title: textblocks
      1: new version, second pass needed
      2: writing blocks to --
      3: reading blocks from --
      4: second pass needed
      5: -- not hidden
      6: -- hidden and processed
      7: -- hidden
      8: -- typeset
      9: -- not typeset
     10: -- loaded and processed
     11: -- loaded and typeset
     12: -- skipped
\stopmessages

\startmessages  german  library: textblocks
  title: textblock
      1: neue Version, zweiter Durchlauf benoetigt
      2: schreibe Bloecke zu --
      3: lese Bloecke von --
      4: zweiter Durchlauf benoetigt
      5: -- nicht verborgen
      6: -- verborgen und verarbeitet
      7: -- verborgen
      8: -- gesetzt
      9: -- nicht gesetzt
     10: -- geladen und verarbeitet
     11: -- geladen und gesetzt
     12: -- ausgelassen
\stopmessages

\startmessages  czech  library: textblocks
  title: textovyblok
      1: nova verze, je treba druhy beh
      2: zapisuji bloky do --
      3: ctu bloky z --
      4: je treba druhy beh
      5: -- neni skryto
      6: -- skryto a zpracovano
      7: -- skryto
      8: -- vysazeno
      9: -- nevysazeno
     10: -- nacteno a zpracovano
     11: -- nacteno a vysazeno
     12: -- preskoceno
\stopmessages

\unprotect 

% PAS OP! 

\def\checknummer#1%
  {\bgroup
%\message{\the\blocklevel}\wait
   \ifdoingblocks
     \doifelsevalue{\s!number#1\c!blokwijze}{\v!nee}
       {\dochecknummer{#1}}
       {\setblockcounters    % dit kan sneller omdat de waarden
        \dochecknummer{#1}}% % en het type bekend zijn
   \else
     \dochecknummer{#1}%
   \fi
   \egroup}

\def\maakvoorafgaandenummer[#1]%
  {\bgroup
%\message{\the\blocklevel}\wait
   \ifdoingblocks
     \doifelsevalue{\s!number#1\c!blokwijze}{\v!nee}
       {\domaakvoorafgaandenummer[#1]}%
       {\setblockcounters               % dit kan sneller omdat de waarden
        \domaakvoorafgaandenummer[#1]}% % en het type bekend zijn
   \else
     \domaakvoorafgaandenummer[#1]%
   \fi
   \egroup}

% \EveryPar%
%   {\doglobal\newcounter\NOfLines}
%
% \EveryLine%
%   {\doglobal\increment\NOfLines%
%    \hskip-3em%
%    \hbox to 3em{\hss\NOfLines\hskip1em}}

\def\processnextbufferline#1#2#3%
  {\relax % checken waarom eerdere macro dit nodig heeft / supp-mps run
   \convertargument#1 \to\next
   \doifinstringelse{\endofblock}{\next}
     {\ifnum\nestedbufferlevel=0\relax % \relax ?
        \def\next{#2}%
      \else
        \decrement\nestedbufferlevel\relax
        \def\next{#3}%
      \fi}
     {\doifinstringelse{\beginofblock}{\next}
        {\increment\nestedbufferlevel\relax
         \def\next{#3}}
        {\def\next{#3}}}%
   \next}

\def\dodostartbuffer[#1][#2][#3]%
  {\showmessage{\m!systems}{15}{#1}%
   \doifelse{#3}{}
     {\letbeundefined{\e!stop\e!buffer}% % \let\stopbuffer=\relax   % \undefined
      \@EA\@EA\@EA\convertargument\@EA\e!start\e!buffer\to\beginofblock % else a space
      \@EA\@EA\@EA\convertargument\@EA\e!stop\e!buffer\to\endofblock
      \let\processnextblockline=\processnextbufferline}
     {\letbeundefined{#3}% \letvalue{#3}=\relax     % \undefined
      \@EA\convertargument\csname#2\endcsname\to\beginofblock
      \@EA\convertargument\csname#3\endcsname\to\endofblock}%
   \def\closeblock%
     {\immediate\closeout\tmpblocks
      \egroup
      \getvalue{#3}}%
   \doifelsenothing{#1}
     {\immediate\openout\tmpblocks=\TEXbufferfile{\jobname}}
     {\immediate\openout\tmpblocks=\TEXbufferfile{#1}}%
   \newcounter\nestedbufferlevel
   \setupcopyblock
   \let\writeoutblocks\gobbleoneargument
   \copyblockline}

\def\dostartbuffer%
  {\bgroup
   \obeylines % nodig, anders gaat 't fout als direct \starttabel (bv)
   \dotripleempty\dodostartbuffer}

\letvalue{\e!start\e!buffer}\dostartbuffer

% \setbuffer[name]#2\endbuffer : saves to file #1.tmp

\def\setbuffer[#1]#2\endbuffer%
  {\immediate\openout\tmpblocks=\TEXbufferfile{#1}%
   \convertargument#2\to\ascii
   \immediate\write\tmpblocks{\ascii}%
   \immediate\closeout\tmpblocks}

\def\dobuffer#1[#2]#3%
  {\def\dodobuffer##1%
      {\showmessage{\m!systems}{#1}{##1}%
       \beginrestorecatcodes
       #3{\TEXbufferfile{##1}}{}{}%
       \endrestorecatcodes}%
   \doifelsenothing{#2}
     {\dodobuffer\jobname}
     {\processcommalist[#2]\dodobuffer}}

\def\haalbuffer%
  {\dodoubleempty\dohaalbuffer}

\def\dohaalbuffer[#1][#2]%
  {\iffirstargument
     \dodohaalbuffer[][#1]%
   \else
     \dodohaalbuffer[#1][#2]%
   \fi}

\def\dodohaalbuffer[#1][#2]%
  {\getvalue{\??bu#1\c!voor}%
   \dobuffer{16}[#2]\readjobfile
   \getvalue{\??bu#1\c!na}}

\def\typebuffer%
  {\dodoubleempty\dotypebuffer}

\def\dotypebuffer[#1][#2]%
  {\iffirstargument
     \dobuffer{17}[#1]\typefile
   \else
     \dobuffer{17}[#2]\typefile
   \fi}

\def\stelbufferin%
  {\dodoubleempty\dostelbufferin}

\def\dostelbufferin[#1][#2]%
  {\ifsecondargument
     \getparameters[\??bu#1][#2]%
   \else
     \getparameters[\??bu][#1]%
   \fi}

\def\dodefinieerbuffer[#1]%
  {\iffirstargument % else problems
     \doglobal\increment\nofdefinedbuffers
     \setevalue{\e!start#1}%
       {\noexpand\dostartbuffer[def-\nofdefinedbuffers][\e!start#1][\e!stop#1]}%
     \setevalue{\e!haal#1}%
       {\noexpand\dodohaalbuffer[#1][def-\nofdefinedbuffers]}%
     \setevalue{\e!type#1}%
       {\noexpand\dodotypebuffer[#1][def-\nofdefinedbuffers]}%
   \fi}

\def\definieerbuffer%
  {\dosingleargument\dodefinieerbuffer}

\def\blockversion {1996.03.10}

\def\@@blockerrormessage%
  {\showmessage{\m!textblocks}{1}{}%
   \global\let\@@blockerrormessage=\relax}

\def\thisisblockversion#1%
  {\doifnot{\blockversion}{#1}%
     {\@@blockerrormessage\endinput}}

\def\stopcopyingblocks%
  {\ifcopyingblocks
     \immediate\closeout\outblocks
     \copyblockfile
     \global\copyingblocksfalse
   \fi}

\def\dodosetblockcounters[#1:#2]#3%
  {\setvalue{\??se\s!old#3}{#1}%
   \doifnot{#3}{\lastsection}
     {\dodosetblockcounters[#2:0]{\getvalue{\??se#3\c!na}}}}

\def\dosetblockcounters[#1#2::#3]%
  {\ifblockpermitted
     \dodosetblockcounters[#3:0]\firstsection
     \setsectiontype[#1]%
     \def\@@sectionvalue##1{\getvalue{\??se\s!old##1}}%
     \def\@@sectionconversion##1##2{##2}% to get rid of {##2}
   \fi}

\let\blockstatus\empty

\def\setblockcounters%
  {\ifx\blockstatus\empty \else
     \@EA\dosetblockcounters\@EA[\blockstatus]%
   \fi}

\def\getblockstatus#1%
  {\dosetblklevel{\getvalue{\??by\@@bscriterium}}%
   \doifblklevelelse[#1]
     {\global\blockpermittedtrue}
     {\global\blockpermittedfalse}%
   \def\blockstatus{#1}}

\def\setupblockparameters%
  {\dodoubleargument\dosetupblockparameters}

\def\dosetupblockparameters[#1][#2]%
  {\getparameters[\??tb#1][#2]}

\beginTEX

\def\blockparameter#1#2%
  {\csname\@EA\ifx\csname\??tb#1#2\endcsname\relax empty\else\??tb#1#2\fi\endcsname}

\endTEX

\beginETEX \ifcsname

\def\blockparameter#1#2%
  {\@EA\csname\ifcsname\??tb#1#2\endcsname\??tb#1#2\else empty\fi\endcsname}

\endETEX

\ifx\outblocks\undefined \newwrite\outblocks \fi
\ifx\inpblocks\undefined \newread \inpblocks \fi
\ifx\tmpblocks\undefined \newwrite\tmpblocks \fi
\ifx\blockbox \undefined \newbox  \blockbox  \fi

\newif\ifcopyingblocks
\newif\ifvisible         \visibletrue
\newif\ifblockpermitted
\newif\iftmpblockstarted
\newif\ifoldinbijlagen
\newif\ifdoingblocks

\newcount\blocklevel     \blocklevel=0

\def\setblocklevel#1%
  {\global\advance\blocklevel by #11
   \ifnum\blocklevel>2\relax\doingblockstrue\else\doingblocksfalse\fi}

\def\opentmpblock%
  {\immediate\openout\tmpblocks=\TEXbufferfile{\f!utilityfilename\the\blocklevel}}

\def\closetmpblock%
  {\immediate\write\tmpblocks{}%   een lege regel is handig voor \par commando's
   \immediate\closeout\tmpblocks}

\def\writetmpblock#1%
  {\iftmpblockstarted
     \immediate\write\tmpblocks{#1}%
   \else
     \doifsomething{#1}
       {\tmpblockstartedtrue
        \immediate\write\tmpblocks{\string#1}}%
   \fi}

\def\startcopyingblocks%
  {\global\copyingblocksfalse}

\def\checkcopyingblocks%
  {\ifcopyingblocks
   \else
     \immediate\openout\outblocks\f!utilityfilename.\f!blockextension
     \immediate\write\outblocks{\string\thisisblockversion{\blockversion}}%
     \global\copyingblockstrue
   \fi}

\def\stopcopyingblocks%
  {\ifcopyingblocks
     \immediate\closeout\outblocks
     \copyblockfile
     \global\copyingblocksfalse
   \fi}

\def\geenblokkenmeer%
  {\stopcopyingblocks}

\def\copyblockfile
  {\ifcopyingblocks
     \begingroup
     \showmessage{\m!textblocks}{2}{\jobname.\f!blockextension}%
     \openlocin{\inpblocks}{\f!utilityfilename.\f!blockextension}%
     \immediate\openout\outblocks\jobname.\f!blockextension
     \setupcopyblock
     \catcode`\^^M=\@@ignore\relax
     \def\copynextline
       {\read\inpblocks to \!!stringa
        \immediate\write\outblocks{\!!stringa}%
        \ifeof\inpblocks\else\expandafter\copynextline\fi}%
     \copynextline
     \immediate\closein\inpblocks
     \immediate\closeout\outblocks
     \immediate\openout\tmpblocks\f!utilityfilename.\f!blockextension
     \immediate\closeout\tmpblocks
     \endgroup
   \fi}

\def\loadallblocks#1%
  {\beginrestorecatcodes
\catcode`\^^M=\@@endofline\relax
   \readjobfile{#1.\f!blockextension}
     {\showmessage{\m!textblocks}{3}{#1.\f!blockextension}}
     {\showmessage{\m!textblocks}{4}{}}%
   \endrestorecatcodes}

\def\setupcopyblock%
  {\dostepwiserecurse{1}{255}{1}{\catcode\recurselevel=\@@other}%
   \obeylines}

\def\writeoutblocks%
  {\immediate\write\outblocks}

\def\processnextblocklineAB#1#2#3%
  {\convertargument#1 \to\next
   \doifinstringelse{\endofblockA}{\next}
     {\def\next{#2}}
     {\doifinstringelse{\endofblockB}{\next}
       {\def\next{#2}}
       {\def\next{#3}}}%
   \next}

\bgroup
\obeylines
\gdef\copyblocklineAB#1
  {\processnextblocklineAB{#1}%
     {\closeblock}%
     {\writeoutblocks{#1}%
      \writetmpblock{#1}%
      \copyblocklineAB}}
\gdef\skipblocklineAB#1
  {\processnextblocklineAB{#1}%
     {\closeblock}%
     {\skipblocklineAB}}
\egroup

\def\processnextblockline#1#2#3%
  {\convertargument#1 \to\next
   \doifinstringelse{\endofblock}{\next}
     {\def\next{#2}}
     {\def\next{#3}}%
   \next}

\bgroup
\obeylines
\gdef\copyblockline#1
  {\processnextblockline{#1}%
     {\closeblock}%
     {\writeoutblocks{#1}%
      \writetmpblock{#1}%
      \copyblockline}}
\gdef\skipblockline#1
  {\processnextblockline{#1}%
     {\closeblock}%
     {\skipblockline}}
\egroup

\def\skipblock#1%
  {\checkcopyingblocks
   \@EA\convertargument\string\thiswasblock{#1}\to\endofblock
%testen : \expanded{\convertargument\string\thiswasblock{#1}\noexpand\to\noexpand\endofblock}%
   \let\openblock=\begingroup
   \let\closeblock=\endgroup
   \openblock
   \setupcopyblock
   \skipblockline}

\def\doafterblock#1#2{}
\def\dobeforeblock#1#2{}

\def\thisisblock#1%
  {\executeifdefined{\s!thisisblock#1}{\skipblock{#1}}}

\def\thiswasblock#1%
  {\getvalue{\s!thiswasblock#1}}

\def\saveblock#1#2%
  {\checkcopyingblocks
   \obeylines
   \@EA\@EA\@EA\convertargument\@EA\string\csname\e!eindvan#1\endcsname\to\endofblockA
%testen:  \expanded{\convertargument\string\csname\e!eindvan#1\endcsname\to\endofblockA}%
   \@EA\convertargument\string\eindvanblok[#1]\to\endofblockB % MULTI LINGUAL MAKEN
   \def\openblock%
     {\dobeforeblock{#1}{#2}%
      \opentmpblock
      \begingroup
      \makesectionformat
      \immediate\write\outblocks{}%
      \immediate\write\outblocks{\string\thisisblock{#1}{\sectionformat}[#2]}}%
   \def\closeblock%
     {\immediate\write\outblocks{}%   handig voor \par commando's
      \immediate\write\outblocks{\string\thiswasblock{#1}}%
      \endgroup
      \closetmpblock
      \doafterblock{#1}{#2}%
      \egroup}%
   \openblock
   \setupcopyblock
   \copyblocklineAB}

\def\copyblock%
  {\let\opentmpblock\empty
   \let\closetmpblock\empty
   \let\writetmpblock\gobbleoneargument
   \saveblock}

\def\loadoneblock%
  {\edef\blockfilename{\TEXbufferfile{\f!utilityfilename\the\blocklevel}}%
   \setblocklevel+%
   \readjobfile{\blockfilename}{}{}%
   \setblocklevel-}%

\def\dodefinieerblok[#1]%
  {\passeerblok[#1]%
   \handhaafblokken[#1]%
   \stelblokin
     [#1]
     [\c!voor=\blanko,
      \c!na=\blanko,
      \c!binnen=,
      \c!letter=,
      \c!file=\jobname]}

\def\definieerblok%
  {\dosingleargumentwithset\dodefinieerblok}

\def\dostelblokin[#1][#2]%
  {\getparameters[\??tb#1][#2]}

\def\stelblokin%
  {\dodoubleargumentwithset\dostelblokin}

\def\passeerblok[#1]%
  {\setvalue{\s!thisisblock#1}##1[##2]%
     {\skipblock{#1}}}

\def\doverbergblok[#1][#2][#3]%
  {\doifassignmentelse{#3}
     {\def\next{\dodoverbergblok[#1][#2][][#3]}}
     {\def\next{\dodoverbergblok[#1][#2][#3][]}}%
   \next}

\def\dodoverbergblok[#1][#2][#3][#4]%
  {\doifelsenothing{#2}
     {\global\blockpermittedfalse
      \edef\bloktitel{#1}}
     {\doifelsenothing{#3}
        {\global\blockpermittedtrue
         \edef\bloktitel{#1}}
        {\doifcommonelse{#2}{#3}
           {\global\blockpermittedfalse
            \edef\bloktitel{#1:#2}}
           {\global\blockpermittedtrue
            \edef\bloktitel{#1:#3}}}}%
   \ifblockpermitted
     \showwarning{\m!textblocks}{5}{\bloktitel}%
     \def\next%
       {\def\dobeforeblock####1####2%
          {\begingroup}%
        \def\doafterblock####1####2%
          {\endgroup
           \doexecuteloadedblock{#1}{#4}}%
        \saveblock{#1}{#3#4}}%
   \else
     \doifinsetelse{+}{#3}
       {\showwarning{\m!textblocks}{6}{\bloktitel}%
        \def\next%
          {\def\dobeforeblock####1####2%
             {\begingroup
              \global\visiblefalse}%
           \def\doafterblock####1####2%
             {{\setbox0=\vbox
                 {\catcode`\^^M=\@@endofline\relax
                  \loadoneblock
                  \par}}%
              \endgroup}%
           \saveblock{#1}{#3#4}}}%
       {\showwarning{\m!textblocks}{7}{\bloktitel}%
        \def\next%
          {\def\dobeforeblock####1####2%
             {\begingroup
              \globaldefs=-1\relax}%
           \def\doafterblock####1####2%
             {\endgroup}%
           \copyblock{#1}{#3#4}}}%
   \fi
   \next}

\def\doverbergblokken[#1][#2]%
  {\def\docommando##1%
     {\setvalue{\e!beginvan##1}%
        {\bgroup\obeylines\dotripleempty\doverbergblok[##1][#2]}}%
   \processcommalist[#1]\docommando}

\def\verbergblokken%
  {\dodoubleempty\doverbergblokken}

\def\doexecuteloadedblock#1#2%
  {\blockpermittedtrue % ?
   \bgroup % before \c!voor (think of: \c!voor=\startitemize)
   \dosetupblockparameters[#1][#2]% voor 'voor'? 
   \getvalue{\??tb#1\c!voor}%
   \doattributes{\??tb#1}\c!letter\c!kleur{}%
   \visibletrue
   \catcode`\^^M=\@@endofline\relax
   \getvalue{\??tb#1\c!binnen}%
   \loadoneblock
   \par
   \getvalue{\??tb#1\c!na}
   \egroup}

\def\dohandhaafblok[#1][#2][#3]%
  {\doifassignmentelse{#3}
     {\def\next{\dodohandhaafblok[#1][#2][][#3]}}
     {\def\next{\dodohandhaafblok[#1][#2][#3][]}}%
   \next}

\def\dodohandhaafblok[#1][#2][#3][#4]%
  {\doifelsenothing{#2}
     {\global\blockpermittedtrue
      \edef\bloktitel{#1}}
     {\doifcommonelse{#2}{#3}
        {\global\blockpermittedtrue
         \edef\bloktitel{#1:#2}}
        {\doifinsetelse{\v!alles}{#2}
           {\doifelse{#3}{}
              {\global\blockpermittedtrue
               \edef\bloktitel{#1}}
              {\global\blockpermittedfalse
               \edef\bloktitel{#1:#3}}}
           {\global\blockpermittedfalse
            \doifelse{#3}{}
              {\edef\bloktitel{#1}}
              {\edef\bloktitel{#1:#3}}}}}%
   \ifblockpermitted
     \showwarning{\m!textblocks}{8}{\bloktitel}%
     \def\dobeforeblock##1##2%
       {\begingroup}%
     \def\doafterblock##1##2%
       {\endgroup
        \doexecuteloadedblock{#1}{#4}}%
   \else
     \showwarning{\m!textblocks}{9}{\bloktitel}%
   \fi
   \saveblock{#1}{#3#4}}

\def\dohandhaafblokken[#1][#2]%
  {\def\docommando##1%
     {\setvalue{\e!beginvan##1}%
        {\bgroup\obeylines\dotripleempty\dohandhaafblok[##1][#2]}}%
   \processcommalist[#1]\docommando}

\def\handhaafblokken%
  {\dodoubleempty\dohandhaafblokken}

\newconditional\processblockstatus
\newconditional\dummyblockstatus
\newconditional\blockassignmentstatus

\def\dodogebruikblok#1#2#3#4%
  {\getblockstatus{#2}%
   \ifblockpermitted
     \setfalse\dummyblockstatus
     \doifassignmentelse{#3}
       {\settrue \blockassignmentstatus}
       {\setfalse\blockassignmentstatus}%
     \doifelsenothing{#4}
       {\edef\bloktitel{#1}}
       {\ifconditional\blockassignmentstatus
          \edef\bloktitel{#1}%
        \else
          \doifnotcommon{#3}{#4}
            {\ifconditional\processblockstatus
               \settrue\dummyblockstatus
             \else
               \global\blockpermittedfalse
             \fi}%
          \edef\bloktitel{#1:#3}%
        \fi}%
   \else
     \edef\bloktitel{#1}%
   \fi
   \ifblockpermitted
     \setblocklevel+%
     \ifconditional\blockassignmentstatus \else
       \doifinset{-}{#3}{\settrue\dummyblockstatus}%
     \fi
     \ifconditional\dummyblockstatus
       \showwarning{\m!textblocks}{10}{\bloktitel}%
       \setvalue{\s!thiswasblock#1}%
         {\par
          \egroup
          \setblocklevel-}%
       \def\next%
         {\setbox0=\vbox\bgroup
          \ifconditional\blockassignmentstatus
            \dosetupblockparameters[#1][#3]%
          \fi}%
     \else
       \showwarning{\m!textblocks}{11}{\bloktitel}%
       \setvalue{\s!thiswasblock#1}%
         {\par
          \getvalue{\??tb#1\c!na}%
          \egroup
          \setblocklevel-}%
       \def\next%
         {\bgroup
          \ifconditional\blockassignmentstatus
            \dosetupblockparameters[#1][#3]%
          \fi
          \getvalue{\??tb#1\c!voor}%
          \doattributes{\??tb#1}\c!letter\c!kleur{}%
          \visibletrue
          \getvalue{\??tb#1\c!binnen}}%
     \fi
   \else
     \def\next%
       {\showwarning{\m!textblocks}{12}{\bloktitel}%
        \skipblock{#1}}%
   \fi
   \next}

\def\dogebruikblok[#1][#2]%
  {\setvalue{\s!thisisblock#1}##1[##2]%
     {\dodogebruikblok{#1}{##1}{##2}{#2}}}

\def\dodogebruikblokken[#1][#2]%
  {\def\docommando##1%
     {\dogebruikblok[##1][#2]}%
   \processcommalist[#1]\docommando
   \dogetcommalistelement1\from#1\to\commalistelement
   \doifdefined{\??tb\commalistelement\c!file}
     {\loadallblocks{\getvalue{\??tb\commalistelement\c!file}}}%
   \endgroup}

\def\dogebruikblokken%
  {\begingroup
   \doassign[\??bs][\c!criterium=\v!alles]%
   \dodoubleempty\dodogebruikblokken}

\def\gebruikblokken%
  {\setfalse\processblockstatus\dogebruikblokken}

\def\verwerkblokken%
  {\settrue \processblockstatus\dogebruikblokken}

\def\doselecteerblokken[#1][#2][#3]%
  {\doifelsenothing{#3}
     {\getparameters[\??bs][#2]%
      \dogebruikblokken[#1][]}
     {\getparameters[\??bs][#3]%
      \dogebruikblokken[#1][#2]}}%

\def\selecteerblokken%
  {\begingroup
   \doassign[\??bs][\c!criterium=\v!alles]%
   \dotripleempty\doselecteerblokken}

\def\beginvanblok[#1]%  % er wordt ook gechecked op \eindvanblok[..]
  {\getvalue{\e!beginvan#1}}

% the buffer mechanism handles nesting, add some switch

\setvalue{\e!start\e!verbergen}%
  {\dostartbuffer[buf-\nofpostponedblocks]
     [\e!start\e!verbergen][\e!stop\e!verbergen]}

\stelbufferin
  [\c!voor=,
   \c!na=]

\protect \endinput 
