From: Jaroslav Hajtmar <hajtmar@gyza.cz>
To: Wolfgang Schuster <schuster.wolfgang@googlemail.com>
Cc: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Finding values of the context macros inside Lua functions (=expansion inside Lua functions?)
Date: Sun, 17 Jul 2011 14:42:04 +0200 [thread overview]
Message-ID: <4E22D89C.6060609@gyza.cz> (raw)
In-Reply-To: <37B73A08-F808-4120-AF73-D313BD575015@googlemail.com>
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
___________________________________________________________________________________
next prev parent reply other threads:[~2011-07-17 12:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-17 12:01 Jaroslav Hajtmar
2011-07-17 12:19 ` Wolfgang Schuster
2011-07-17 12:42 ` Jaroslav Hajtmar [this message]
2011-07-17 12:53 ` Wolfgang Schuster
2011-07-17 13:10 ` Jaroslav Hajtmar
2011-07-17 13:40 ` Wolfgang Schuster
2011-07-17 13:49 ` Jaroslav Hajtmar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4E22D89C.6060609@gyza.cz \
--to=hajtmar@gyza.cz \
--cc=ntg-context@ntg.nl \
--cc=schuster.wolfgang@googlemail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).