ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Learning LuaTeX : Invoice
@ 2011-02-20 11:55 Henning Hraban Ramm
  2011-02-20 12:07 ` Henning Hraban Ramm
  2011-02-20 12:08 ` Wolfgang Schuster
  0 siblings, 2 replies; 19+ messages in thread
From: Henning Hraban Ramm @ 2011-02-20 11:55 UTC (permalink / raw)
  To: mailing ConTeXt users list for

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)

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2011-02-22 10:55 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-20 11:55 Learning LuaTeX : Invoice Henning Hraban Ramm
2011-02-20 12:07 ` Henning Hraban Ramm
2011-02-20 12:08 ` Wolfgang Schuster
2011-02-20 12:58   ` Henning Hraban Ramm
2011-02-20 13:29     ` Wolfgang Schuster
2011-02-20 13:29     ` Henning Hraban Ramm
2011-02-20 13:41       ` Wolfgang Schuster
2011-02-20 14:49         ` Henning Hraban Ramm
2011-02-20 15:12           ` Hans Hagen
2011-02-20 15:09         ` Hans Hagen
2011-02-20 19:16           ` Henning Hraban Ramm
2011-02-20 20:20             ` Philipp Gesang
2011-02-20 20:28               ` Wolfgang Schuster
2011-02-20 23:28                 ` Hans Hagen
2011-02-22  9:47               ` Henning Hraban Ramm
2011-02-22  9:51                 ` luigi scarso
2011-02-22 10:01                   ` Wolfgang Schuster
2011-02-22 10:14                     ` luigi scarso
2011-02-22 10:55                       ` Henning Hraban Ramm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).