[NTG-context] issue with \processaction

Aditya Mahajan adityam at umich.edu
Tue Mar 18 23:30:40 CET 2014


On Tue, 18 Mar 2014, Pablo Rodriguez wrote:

> The next one (AFAIK) should work on every OS:
>
> \startluacode
>     local user  = ""
>     local users = {
>         ["ousia"] = 1,
>     }
>     function document.CheckUser()
>         user = os.resultof("echo ousia")
>         context.verbatim(user)
>     end
>
>     function document.UserNumber(name)
>         context.verbatim(users[name or user] or 0)
>     end
> \stopluacode
>
> \def\CheckUser {\ctxlua{document.CheckUser ()}}
> \def\UserNumber{\ctxlua{document.UserNumber()}}
>
> \starttext
> This is user \CheckUser with number \UserNumber.
> \stoptext

(Untested)

Change `local user` by

~~~
userdata = userdata or {}
userdata.user = ""
~~~

and all other occurances of `user` by `userdata.user`.

Aditya


More information about the ntg-context mailing list