Thanx Wolfgang.
But I guess I was wrong to express..
I need to pass parameter '\\macroI' to the function and turn it up a
inside luafunction expand to its value.
Ie when \def\macroI{6}
Then I need when I make in your example \ctxlua{test("\\macroI")} get
the result :
"The argument “6” is a positive number" and not result "The argument “6”
is a string."
see: I modify your example :
\startluacode
function test(arg) -- use thirddata namespace for real functions
if type(tonumber(arg)) == "number" then
if tonumber(arg) > 0 then
context("The argument \\quotation{%s} is a positive
number",arg)
else
context("The argument \\quotation{%s} is a negative
number",arg)
end
else
context("The argument \\quotation{%s} is a string.",arg)
end
end
\stopluacode
\starttext
\ctxlua{test("7")}
\ctxlua{test("-4")}
\ctxlua{test("text")}
\def\macroI{6}
\ctxlua{test("\macroI")}
\ctxlua{test("\\macroI")}
\stoptext
Dne 17.7.2011 14:19, Wolfgang Schuster napsal(a):
Am 17.07.2011 um 14:01 schrieb Jaroslav Hajtmar:
> Hello all,
>
> For several hours trying to find solutions of problem.
>
> My minimal example (I mention it at the end of email) for clear reasons show, that :
>
> 7 is not number.
> 7 is number.
> 7is not number.
> 7is not number.
>
> In the first is argument '\value' negotiable to the value, in second it is not possible (but for clear reasons too).
>
> I would need to find from argument ie macro '\\value' in the LUA function its numerical value.
> Is there any function that would do that?
>
> I need something as a function of context (...), which would, however, its output is not located into ConTeXt, but its result get to back to a Lua function or into variable.
> It is something like the expansion of an existing ConTeXt macro to its value.
\startluacode
function test(arg) -- use thirddata namespace for real functions
if type(tonumber(arg)) == "number" then
if tonumber(arg)> 0 then
context("The argument \\quotation{%s} is a positive
number",arg)
else
context("The argument \\quotation{%s} is a negative
number",arg)
end
else
context("The argument \\quotation{%s} is a string.",arg)
end
end
\stopluacode
\starttext
\ctxlua{test("7")}
\ctxlua{test("-4")}
\ctxlua{test("text")}
\stoptext
Wolfgang
___________________________________________________________________________________
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
___________________________________________________________________________________