From: Jaroslav Hajtmar <hajtmar@gyza.cz>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Finding values of the context macros inside Lua functions (=expansion inside Lua functions?)
Date: Sun, 17 Jul 2011 14:01:37 +0200 [thread overview]
Message-ID: <4E22CF21.9060603@gyza.cz> (raw)
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.
Thanx Jaroslav
Here is my minimal example:
\startluacode
function test(arg)
if type(arg)=='number' then
context(arg.." is number.\\par ")
else
context(arg.." is not number.\\par")
end
if type(tonumber(arg))=='number' then
context(arg.." is number.\\par ")
else
context(arg.." is not number.\\par")
end
end
\stopluacode
\starttext
\def\value{7}
\ctxlua{test('\value');}
\blank[big]
\ctxlua{test('\\value');}
\stoptext
___________________________________________________________________________________
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 reply other threads:[~2011-07-17 12:01 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-17 12:01 Jaroslav Hajtmar [this message]
2011-07-17 12:19 ` Wolfgang Schuster
2011-07-17 12:42 ` Jaroslav Hajtmar
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=4E22CF21.9060603@gyza.cz \
--to=hajtmar@gyza.cz \
--cc=ntg-context@ntg.nl \
/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).