Am 2011-02-20 um 13:08 schrieb Wolfgang Schuster:
local amount = hours * perhour
Thank you - I guess you meant that "local". I tried that, but since my error was in the call... anyway. Please consider the following nearly-minimal example: \starttext \startluacode userdata = userdata or {} userdata.invoice = { sum = 0, hours = 0, perhour = 100 } function userdata.numberformat(amount) context(string.gsub(string.format("\%.2f", amount), "%.", ",")) end function userdata.InvoiceLine(text, hours) context.NC() context(text) context.NC() userdata.numberformat(hours) context("\\,h") context.NC() context.NC() userdata.numberformat(hours * userdata.invoice.perhour) context("\\,€") context.NC() context.NR() userdata.invoice.sum = userdata.invoice.sum + hours * userdata.invoice.perhour userdata.invoice.hours = userdata.invoice.hours + hours end function userdata.InvoiceSumLine(text) context.HL() context.NC() context(text) context.NC() userdata.numberformat(userdata.invoice.hours) context("\\,h") context.NC() userdata.numberformat(userdata.invoice.perhour) context("\\,€/h") context.NC() userdata.numberformat(userdata.invoice.sum) context("\\,€") context.NC() context.NR() end \stopluacode \starttabulate[|lw(8cm)|rg(,)w(2cm)|rg(,)w(2cm)|rg(,)w(3cm)|] %\ctxlua{userdata.InvoiceLine("Play with \\LUATEX", 2.5)} \ctxlua{userdata.InvoiceLine("Do some \\CONTEXT", 0.5)} \ctxlua{userdata.InvoiceSumLine("Sum")} \stoptabulate \stoptext That seems to work so far, but invoice.hours and invoice.sum are always doubled! In my letter setup, it’s even quadrupled! I guess my functions gets called several times, but how can I avoid that? Greetlings from Lake Constance! Hraban --- http://www.fiee.net/texnique/ http://wiki.contextgarden.net https://www.cacert.org (I'm an assurer)