Am 18.03.2014 um 22:09 schrieb Pablo Rodriguez
On 03/18/2014 07:55 PM, Hans Hagen wrote:
On 3/18/2014 6:58 PM, Pablo Rodriguez wrote:
\def\CheckUser{\cldcommand{sprint(tex.vrbcatcodes,os.resultof"whoami")}} \def\UserNumber{\processaction[\CheckUser][ousia=>1, unknown=>user unknown]}
\starttext This is user \CheckUser\ with number \UserNumber. \stoptext
What am I doing wrong here?
you output vrbcatcodes strings while you test using ctx catcodesn
of course i'd use lua for all of it:
\startluacode local user = "" local users = { ["oasi"] = 1, } function document.CheckUser() user = os.resultof("whoami") 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
Many thanks for your reply, Hans.
I’m afraid that the user doesn’t get recognized (I corrected the user name above).
The same applies to your examples because your test won’t work on our machines ;)
Is there no way to do it with \processaction?
Only when you ensure the text you get from Lua has the normal cathode regime and when you special characters like \ in the result you have to convert them to \letterbackslash etc. which isn’t simpler than Hans solution. The advantage of Hans solution is that you don’t have to care about expansion. Wolfgang