ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* [NTG-context] Numbers obtained by commands <\datasetvariable> cannot be copied to counters
@ 2024-05-29 12:05 ai2472206007
  2024-05-29 12:48 ` [NTG-context] " Taco Hoekwater
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: ai2472206007 @ 2024-05-29 12:05 UTC (permalink / raw)
  To: ntg-context

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

Muyik
___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [NTG-context] Re: Numbers obtained by commands <\datasetvariable> cannot be copied to counters
  2024-05-29 12:05 [NTG-context] Numbers obtained by commands <\datasetvariable> cannot be copied to counters ai2472206007
@ 2024-05-29 12:48 ` Taco Hoekwater
  2024-05-29 14:32   ` ai2472206007
  2024-05-29 14:30 ` Wolfgang Schuster
  2024-05-29 15:20 ` ai2472206007
  2 siblings, 1 reply; 6+ messages in thread
From: Taco Hoekwater @ 2024-05-29 12:48 UTC (permalink / raw)
  To: mailing list for ConTeXt users



> On 29 May 2024, at 14:05, ai2472206007@yeah.net wrote:
> 
> 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

Works for me (minus comment signs of course):

 ConTeXt  ver: 2024.03.11 09:34 LMTX

Best wishes,
Taco


___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [NTG-context] Re: Numbers obtained by commands <\datasetvariable> cannot be copied to counters
  2024-05-29 12:05 [NTG-context] Numbers obtained by commands <\datasetvariable> cannot be copied to counters ai2472206007
  2024-05-29 12:48 ` [NTG-context] " Taco Hoekwater
@ 2024-05-29 14:30 ` Wolfgang Schuster
  2024-05-29 14:33   ` ai2472206007
  2024-05-29 15:20 ` ai2472206007
  2 siblings, 1 reply; 6+ messages in thread
From: Wolfgang Schuster @ 2024-05-29 14:30 UTC (permalink / raw)
  To: mailing list for ConTeXt users, ai2472206007

ai2472206007@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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [NTG-context] Re: Numbers obtained by commands <\datasetvariable> cannot be copied to counters
  2024-05-29 12:48 ` [NTG-context] " Taco Hoekwater
@ 2024-05-29 14:32   ` ai2472206007
  0 siblings, 0 replies; 6+ messages in thread
From: ai2472206007 @ 2024-05-29 14:32 UTC (permalink / raw)
  To: ntg-context

Thanks, probably interfered with his output in other parts of my command. I didn't locate the error correctly.
___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [NTG-context] Re: Numbers obtained by commands <\datasetvariable> cannot be copied to counters
  2024-05-29 14:30 ` Wolfgang Schuster
@ 2024-05-29 14:33   ` ai2472206007
  0 siblings, 0 replies; 6+ messages in thread
From: ai2472206007 @ 2024-05-29 14:33 UTC (permalink / raw)
  To: ntg-context

Thank you. I will try again.
___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [NTG-context] Re: Numbers obtained by commands <\datasetvariable> cannot be copied to counters
  2024-05-29 12:05 [NTG-context] Numbers obtained by commands <\datasetvariable> cannot be copied to counters ai2472206007
  2024-05-29 12:48 ` [NTG-context] " Taco Hoekwater
  2024-05-29 14:30 ` Wolfgang Schuster
@ 2024-05-29 15:20 ` ai2472206007
  2 siblings, 0 replies; 6+ messages in thread
From: ai2472206007 @ 2024-05-29 15:20 UTC (permalink / raw)
  To: ntg-context

I must have made a mistake with something, I changed a counter and it somehow worked properly. Because I've designed too many counters, I still haven't figured out exactly what the problem is doing. But admittedly, the question I asked is non-existent. It's a problem with my design.
___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-05-29 15:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-29 12:05 [NTG-context] Numbers obtained by commands <\datasetvariable> cannot be copied to counters ai2472206007
2024-05-29 12:48 ` [NTG-context] " Taco Hoekwater
2024-05-29 14:32   ` ai2472206007
2024-05-29 14:30 ` Wolfgang Schuster
2024-05-29 14:33   ` ai2472206007
2024-05-29 15:20 ` ai2472206007

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).