Why does \setvalue not work inside \startbodymatter?

I have a document setup with: \starttext\startfrontmatter(contains all front matter content)\stopfrontmatter \startbodymatter \stopbodymatter \startbackmatter \stopbackmatter\stoptext I was noticing very strange behavior where \setvalue was not showing up as \getvalue. I put it in lots of pllaces, but in the main part of the document, it wasn't working. Its like it was never set. After a lot of testing, I discovered if \setvalue is set inside \startbodymatter, its value stays unset. But I can set it in the front matter, backmatter, anywhere else. Here is my minimum working example, note that \getvalue{B} never appears, it was set within the bodymatter. \setvalue{A}{this is a test} \starttext \startbodymatter \setvalue{B}{Why is hits one missing?} \stopbodymatter \startbackmatter \dostepwiserecurse{1}{3}{1}{ \setvalue{C}{this is yet another test} \getvalue{A} \getvalue{B} \getvalue{C} } \stopbackmatter \stoptext What is going on? Should I no longer be using the \startbodymatter, etc. items? --Joel

On 5/18/2025 5:57 PM, Joel via ntg-context wrote:
I have a document setup with:
\starttext \startfrontmatter (contains all front matter content) \stopfrontmatter
\startbodymatter
\stopbodymatter
\startbackmatter
\stopbackmatter \stoptext
I was noticing very strange behavior where \setvalue was not showing up as \getvalue. I put it in lots of pllaces, but in the main part of the document, it wasn't working. Its like it was never set. After a lot of testing, I discovered if \setvalue is set inside \startbodymatter, its value stays unset. But I can set it in the front matter, backmatter, anywhere else. Here is my minimum working example, note that \getvalue{B} never appears, it was set within the bodymatter.
\setvalue{A}{this is a test}
\starttext
\startbodymatter \setvalue{B}{Why is hits one missing?}
\stopbodymatter
\startbackmatter
\dostepwiserecurse{1}{3}{1}{
\setvalue{C}{this is yet another test}
\getvalue{A} \getvalue{B} \getvalue{C}
}
\stopbackmatter
\stoptext
What is going on? Should I no longer be using the \startbodymatter, etc. items?
\setgvalue (global) or sometimes you need \setxvalue (global and expanded) Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------

Am 18.05.2025 um 17:57 schrieb Joel via ntg-context:
I have a document setup with:
\starttext \startfrontmatter (contains all front matter content) \stopfrontmatter
\startbodymatter
\stopbodymatter
\startbackmatter
\stopbackmatter \stoptext
I was noticing very strange behavior where \setvalue was not showing up as \getvalue. I put it in lots of pllaces, but in the main part of the document, it wasn't working. Its like it was never set. After a lot of testing, I discovered if \setvalue is set inside \startbodymatter, its value stays unset. But I can set it in the front matter, backmatter, anywhere else. Here is my minimum working example, note that \getvalue{B} never appears, it was set within the bodymatter.
\setvalue{A}{this is a test}
\starttext
\startbodymatter \setvalue{B}{Why is hits one missing?}
\stopbodymatter
\startbackmatter
\dostepwiserecurse{1}{3}{1}{
\setvalue{C}{this is yet another test}
\getvalue{A} \getvalue{B} \getvalue{C}
}
\stopbackmatter
\stoptext
What is going on? Should I no longer be using the \startbodymatter, etc. items?
You already got your answer to the problem by Hans but the example below shows why you need \setgavlue. When you use section blocks ConTeXt creates a local group with the environment where command definitions stay local to the group, e.g. the \setvalue setting in the block is forgotten at the end of the block and whatever was set before the block is restored. When you now use \setgvalue to value is set at a global level and is kept even when we leave the group which can be seen with the C value. In your real document you should also avoid short identifiers like A with \setvalue because when you use \setvalue{A}{...} you're doing the same as \def\A{...}. To avoud redefining existing commmands use a prefix for your command names because unlike \def you can use special symbols like : or _ within \setvalue. %%%% begin example \startbuffer[getvalue] \starttabulate[|T||] \NC Joel:A \EQ \getvalue{Joel:A} \NC\NR \NC Joel:B \EQ \getvalue{Joel:B} \NC\NR \NC Joel:C \EQ \getvalue{Joel:C} \NC\NR \stoptabulate \stopbuffer \setupsectionblock[bodypart][page=no] \starttext \setvalue{Joel:A}{First value} \setvalue{Joel:B}{Second value} \getbuffer[getvalue] \startbodymatter \setvalue {Joel:B}{Local value for B} \setgvalue{Joel:C}{Global value for C} \getbuffer[getvalue] \stopbodymatter \getbuffer[getvalue] \stoptext %%%% end example Wolfgang
participants (3)
-
Hans Hagen
-
Joel
-
Wolfgang Schuster