ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Finding values ​​of the context macros inside Lua functions (=expansion inside Lua functions?)
@ 2011-07-17 12:01 Jaroslav Hajtmar
  2011-07-17 12:19 ` Wolfgang Schuster
  0 siblings, 1 reply; 7+ messages in thread
From: Jaroslav Hajtmar @ 2011-07-17 12:01 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-07-17 13:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-17 12:01 Finding values ​​of the context macros inside Lua functions (=expansion inside Lua functions?) Jaroslav Hajtmar
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

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