[NTG-context] Defining commands in \start ... \stop

Xan dxpublica at telefonica.net
Sun Mar 30 19:28:00 CEST 2014


This:

\defineblock[question]
\defineblock[answer]

\defineenumeration[question][text={Question}]
\defineenumeration[answer]  [text={Answer}]

\keepblocks[question]
\hideblocks[answer]


\def\mynewcommand{\dosingleempty\doMyNewCommand}
\def\doMyNewCommand[#1]#2{%
 \iffirstargument
     \beginquestion
       \startquestion #2%
       \stopquestion
     \endquestion
       \beginanswer \startanswer #1%
       \stopanswer \endanswer
 \else
     \beginquestion
       \startquestion #2%
       \stopquestion
     \endquestion
       \incrementcounter[answer]
 \fi
}


\starttext

\chapter{Question}

\beginquestion
	\startquestion
		Question 1.
	\stopquestion
\endquestion

\beginanswer
	\startanswer
		Answer 1.
	\stopanswer
\endanswer

\beginquestion
	\startquestion
		Question 2.
	\stopquestion
\endquestion

\beginanswer
	\incrementcounter[answer]
\endanswer

\beginquestion
	\startquestion
		Question 3.
	\stopquestion
\endquestion

\beginanswer
	\startanswer
		Answer 3.
	\stopanswer
\endanswer

\mynewcommand{Question 5}

\mynewcommand[Resposta 6]{Question 6}

\chapter{Answers}

\useblocks[answer]

\stoptext

does not work


More information about the ntg-context mailing list