On 3/18/2014 6:58 PM, Pablo Rodriguez wrote:
Dear list,

I have the following sample:

\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

which gives me the following output:

     This is user ousia with number user unknown.

What am I doing wrong here?

Many thanks for your help,

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


-----------------------------------------------------------------
                                          Hans Hagen | PRAGMA ADE
              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
    tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                             | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
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
___________________________________________________________________________________

Reply via email to