ai2472206...@yeah.net schrieb am 29.05.2024 um 14:05:
I'm defining a command to generate options for multiple choice questions,
but at the moment I'm stuck at this step.
I want to get a number and assign a value to the counter, but why can't I get
it?
%%%%
\starttext
\definedataset [myset]
\setdataset [myset] [foo=1,boo=4]
\newcount\tempa
\datasetvariable{myset}{1}{boo} % definitely get 4
%\tempa=\datasetvariable{myset}{1}{boo} % why i cannt pass 4 to tempa?
%\number\tempa
\stoptext
%%%%%
If anyone can fix it, thanka very much
You have to add a check to ensure there is a value stored in the
aux-file before you pass the value to the counter. This is necessary
because when you process the document for the first time Context only
saves the value and can access it only in the next run after.
%%%% begin example
\definedataset [myset]
\starttext
\setdataset [myset] [foo=1,boo=4]
\doifelsesomething{\datasetvariable{myset}{1}{boo}}
{\scratchcounter\datasetvariable{myset}{1}{boo}}
{\scratchcounter\zerocount}
boo = \number\scratchcounter
\stoptext
%%%% end example
Wolfgang
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the
Wiki!
maillist : ntg-context@ntg.nl /
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________