[NTG-context] Learning LuaTeX : Invoice

Henning Hraban Ramm hraban at fiee.net
Sun Feb 20 12:55:20 CET 2011


Maybe similar to the "spreadsheet" question:
I'm trying to use Wolfgang's letter module for my invoices and would  
like to use Lua for the sums.
But I fail already at the beginning:

\startluacode
userdata = userdata or {}

userdata.invoice = userdata.invoice or { sum = 0 } -- global table for  
sums

function userdata.singlesum(hours, perhour)
	amount = hours * perhour
	userdata.invoice.sum = userdata.invoice.sum + amount
	global.context(string.gsub(string.format("\%.2f", amount), "%.", ","))
	return amount
end

\stopluacode

gives:

(virtual://viafile.1 unknown preamble key [the character )] unknown  
preamble key [the character )] unknown preamble key [the character )]
! LuaTeX error <main ctx instance>:1: '=' expected near '<eof>'.

system          > tex > error on line 11 in file invoice.tex: LuaTeX  
error  ...

  4     \startluacode
  5     userdata = userdata or {}
  6
  7     userdata.invoice = userdata.invoice or { sum = 0 }
  8
  9     function userdata.singlesum(hours, perhour)
10     	amount = hours * perhour
11 >>  	userdata.invoice.sum = userdata.invoice.sum + amount
12     	global.context(string.gsub(string.format("\%.2f", amount),  
"%.", ","))
13     	return amount
14     end


I can't see what's wrong!?

I tried local and usercode, but didn’t get further.


Greetlings from Lake Constance!
Hraban
---
http://www.fiee.net/texnique/
http://wiki.contextgarden.net
https://www.cacert.org (I'm an assurer)



More information about the ntg-context mailing list