[NTG-context] issue with \processaction

Pablo Rodriguez oinos at gmx.es
Tue Mar 18 23:04:25 CET 2014


On 03/18/2014 10:40 PM, Wolfgang Schuster wrote:
> Am 18.03.2014 um 22:09 schrieb Pablo Rodriguez:
>> On 03/18/2014 07:55 PM, Hans Hagen wrote:
>>> [...]
>>> 
>>> you output vrbcatcodes strings while you test using ctx catcodesn
>>>
>>> of course i'd use lua for all of it:
>>> [...]
>> 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 ;)

You’re right, Wolfgang, I chose the wrong sample.

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

>> 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.

The solution from Hans is great. The only issue there is that it is much
harder to understand for me.

Since this is a minimal part in a way more complex implementation (at
least for me), I really need to use commands that I know what they do.
Pure Lua code is totally unknown to me. I don’t have any background in
programming.

This is the reason why I asked about \processaction.

Many thanks for your reply,


Pablo
-- 
http://www.ousia.tk


More information about the ntg-context mailing list