Great!!! Thanx very much Hans... Normally I do all things in ConTeXt, but I am preparing a beginning tutorial for users of LaTeX and PlainTeX, who would be interested in getting to know the basics LuaTEX. Therefore I am seeking a solution applicable in LuaLaTeX and LuaPlain too. Jaroslav Hajtmar Dne 22.8.2012 14:12, Hans Hagen napsal(a):
On 22-8-2012 13:24, Jaroslav Hajtmar wrote:
Thank to Hans and Peter too. It works in context fine now. I would like realize this same in pure LuaTeX.
I was primarily in the query for it to find Lua equivalent of TeX primitives \newdimen and \newcount (for direct creating new TeX registers) I could use something like "\directlua{tex.newdimen.mydimen}" that would create TeX register "mydimen" and then \directlua{tex.dimen.mydimen=200*2^16} which set value of register and that should be present in TeX for direct use such as "\the\mydimen" etc. I apologize for my naivete :-).
Just do:
tex.dimen[20001] = "100pt"
at the lau end and at the tex end:
\dimen20001=100pt
keep in mind that \newdimen is just an allocator that associates a \cs and the implementation of that is pretty macro package dependent! Starting at 20000 makes sure that you have no clash with existing registers.
Of course, I did not think that the global variable is magically changed the registry value, I just did not know how to implement it. Plus, I had in mind that ConTeXt conversion functions do not work in a clean LuaTEX (without reading about some library functions).
Ok, but keep in mind that clean luatex does not exist. As soon as one starts doing things at the lua end that reflects on the tex end, you have a dependency.
I will add a context.newdimen function so that one can do:
\startluacode
document.mydimen = context.newdimen("MyDimen")
tex.dimen[document.mydimen] = "10pt"
\stopluacode
\the\MyDimen
\MyDimen=100pt
\the\MyDimen
\startluacode context(number.points(tex.dimen[document.mydimen])) \stopluacode
Posting the implemenation makes no sense as it refers to low level context properties that users should not be troubled with.
PS. From the context point of view I see no advantages of using plain. First of all, one can still do pretty plain things in context.
Hans
----------------------------------------------------------------- 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 -----------------------------------------------------------------