[NTG-context] Evaluating a lua expression at the end (again)

2017-02-09 Thread Kumar Appaiah
Dear ConTeXt users, Last time, this is what I wanted, and Hans provided me an example: https://www.mail-archive.com/ntg-context@ntg.nl/msg78079.html However, the example given in that e-mail does not work with my Debian context 2016.05.17.20160523-1. Could you please help me out again? I get:

Re: [NTG-context] Evaluating a Lua expression at the end (repeat)

2016-08-25 Thread Kumar Appaiah
On Thu, Aug 25, 2016 at 5:49 PM, Henri Menke wrote: > Hi Kumar, > > the function job.variables.save seems to save the key in > job.variables.collected.macros instead of job.variables.collected. The > problem is that macros is not created unconditionally, which is why you

Re: [NTG-context] Evaluating a Lua expression at the end (repeat)

2016-08-25 Thread Henri Menke
Hi Kumar, the function job.variables.save seems to save the key in job.variables.collected.macros instead of job.variables.collected. The problem is that macros is not created unconditionally, which is why you might run into a »attempt to index a nil value« error without some manual error

[NTG-context] Evaluating a Lua expression at the end (repeat)

2016-08-25 Thread Kumar Appaiah
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

[NTG-context] Evaluating a Lua expression at the end

2015-04-13 Thread Kumar Appaiah
Hi. I am trying to set up a system where I can use Lua to find a total that I can display at the end. For example, if I set a question paper, after each question, I do a \directlua{total = total + 4}, assuming this question has 4 points. At the top of my document, I now want to say Total points:

Re: [NTG-context] Evaluating a Lua expression at the end

2015-04-13 Thread Norbert Melzer
Sorry, wrong recipient... Am 13.04.2015 14:05 schrieb Norbert Melzer timmel...@gmail.com: If it is possible I'd like to wait for the idris book and get that one. If that's not possible I'm interested in http://www.manning.com/blackheath/ Am 13.04.2015 13:54 schrieb Kumar Appaiah

Re: [NTG-context] Evaluating a Lua expression at the end

2015-04-13 Thread Norbert Melzer
If it is possible I'd like to wait for the idris book and get that one. If that's not possible I'm interested in http://www.manning.com/blackheath/ Am 13.04.2015 13:54 schrieb Kumar Appaiah a.ku...@alumni.iitm.ac.in: Hi. I am trying to set up a system where I can use Lua to find a total that

Re: [NTG-context] Evaluating a Lua expression at the end

2015-04-13 Thread Procházka Lukáš Ing . - Pontex s . r . o .
Hello, another single-pass approach, which uses the fact that you know the questions and their point weights in advance is to form questions into a Lua table and evaluate the total first: local C = context local tab = { {Question 1, 10, }, {Question 2, 20, }, {Question 3, 30, }, }

Re: [NTG-context] Evaluating a Lua expression at the end

2015-04-13 Thread Procházka Lukáš Ing . - Pontex s . r . o .
Hello Kumar, could you provide a (non-working) minimal example? I tried this: local C = context local n = 0 C.starttext() C(A) n = n + 1 C(B) n = n + 1 C(C) n = n + 1 print(***, n) C.stoptext() print(, n) and I got 3 (twice) - what I expected: ... ConTeXt ver:

Re: [NTG-context] Evaluating a Lua expression at the end

2015-04-13 Thread Kumar Appaiah
On Mon, Apr 13, 2015 at 03:32:04PM +0200, Hans Hagen wrote: On 4/13/2015 1:53 PM, Kumar Appaiah wrote: Hi. I am trying to set up a system where I can use Lua to find a total that I can display at the end. For example, if I set a question paper, after each question, I do a \directlua{total =

Re: [NTG-context] Evaluating a Lua expression at the end

2015-04-13 Thread Kumar Appaiah
Dear Lukáš, On Mon, Apr 13, 2015 at 02:26:38PM +0200, Procházka Lukáš Ing. - Pontex s. r. o. wrote: Hello Kumar, could you provide a (non-working) minimal example? I tried this: local C = context local n = 0 C.starttext() C(A) n = n + 1 C(B) n = n + 1 C(C)

Re: [NTG-context] Evaluating a Lua expression at the end

2015-04-13 Thread Hans Hagen
On 4/13/2015 1:53 PM, Kumar Appaiah wrote: Hi. I am trying to set up a system where I can use Lua to find a total that I can display at the end. For example, if I set a question paper, after each question, I do a \directlua{total = total + 4}, assuming this question has 4 points. At the top of