Dear List, Last year, Hans helped me with this example: \starttext \startluacode local name = nil local temp = 0 function document.startwhatever(s) name = s temp = 0 end function document.addwhatever(n) temp = temp + n context(n) end function document.stopwhatever() job.variables.save("document:temp:"..name,temp) end function document.getwhatever(s) context(job.variables.collected["document:temp:"..s]) end \stopluacode \def\startwhatever[#1]{\ctxlua{document.startwhatever("#1")}} \def\stopwhatever {\ctxlua{document.stopwhatever()}} \def\addwhatever #1{\ctxlua{document.addwhatever(#1)}} \def\getwhatever #1{\ctxlua{document.getwhatever("#1")}} total: \getwhatever{foo} \startwhatever[foo] test 1: \addwhatever{10}\par test 2: \addwhatever{20}\par test 3: \addwhatever{30}\par \stopwhatever \stoptext However, on my current ConTeXt on Debian (2016.05.17.20160523-1), I am unable to get it working. It says: lua error > lua error on line 37 in file /tmp/test.tex: /usr/share/texmf/tex/context/base/mkiv/core-uti.lua:165: attempt to index upvalue 'tobesavedmacros' (a nil value) stack traceback: /usr/share/texmf/tex/context/base/mkiv/core-uti.lua:165: in function 'save' [ctxlua]:14: in function 'stopwhatever' [ctxlua]:1: in main chunk 27 \def\getwhatever #1{\ctxlua{document.getwhatever("#1")}} 28 29 total: \getwhatever{foo} 30 31 \startwhatever[foo] 32 33 test 1: \addwhatever{10}\par 34 test 2: \addwhatever{20}\par 35 test 3: \addwhatever{30}\par 36 37 >> \stopwhatever 38 39 \stoptext 40 41 Could you please suggest a workaround? Thanks. Kumar