ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Jaroslav Hajtmar <hajtmar@gyza.cz>
Cc: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Creating TeX dimensions and counters registers directly in Lua
Date: Wed, 22 Aug 2012 13:24:25 +0200	[thread overview]
Message-ID: <5034C169.5080606@gyza.cz> (raw)
In-Reply-To: <5034B542.9030604@wxs.nl>

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

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


One more thanx.
Jaroslav


Here is my pure luatex example. Is there any easy way?

\newdimen\mytexdimension
\mytexdimension 100pt

mytexdimension: .\hbox to\mytexdimension{\the\mytexdimension}.

\directlua{tex.myluadimension = "200pt"}

myluadimension: .\hbox to 
\directlua{tex.print(tex.myluadimension)}{\directlua{tex.print(tex.myluadimension)}}.

\directlua{tex.dimen.mytexdimension = "300pt"}

mytexdimension: .\hbox to\mytexdimension{\the\mytexdimension}.

\def\myluadimension{\directlua{tex.print(tex.myluadimension)}}

myluadimension: .\hbox to\myluadimension{\myluadimension}.

\bye



Dne 22.8.2012 12:32, Hans Hagen napsal(a):
> On 22-8-2012 11:09, Jaroslav Hajtmar wrote:
>> Thanks Wolfgang for the reply,
>> but I must have misunderstood. My point is, that TeX registers was
>> subsequently visible and usable in TeX (eg for width or height of boxes,
>> etc.)
>>
>> Eg. for example, \the\mydimension can see that this does not occur!
>> In addition, I solve the problem at LuaTEX, so ConTeXt converting
>> functions do not work etc. ..
>>
>> Thanx Jaroslav
>>
>> Here is another example:
>>
>> \starttext
>>
>> \newdimen\mytexdimension
>> \mytexdimension=100pt
>>
>>
>> \ctxlua{myluadimension = number.topoints(10000)}
>> \ctxlua{context(myluadimension)}
>>
>> \the\mytexdimension
>> \hbox to\mytexdimension{XXXXX}YYYY
>>
>> % FAILS
>> %\the\myluadimension
>> %\hbox to\myluadimension{XXXXX}YYYY
>
> Of course that fails: why should the globally defined
> lua variable "myluadimension" magically become a \dimen
> register at the tex end? And believe it or not, the context
> conversion function do work, else mkiv wouldn't work.
>
>> \stoptext
>
> Here is the right code:
>
> \starttext
>
> \newdimen\mytexdimension \mytexdimension 100pt
>
> \ruledhbox to\mytexdimension{\the\mytexdimension}
>
> \ctxlua{document.myluadimension = "200pt"}
>
> \ruledhbox to 
> \cldcontext{document.myluadimension}{\cldcontext{document.myluadimension}} 
>
>
> \ctxlua{tex.dimen.mytexdimension = "300pt"}
>
> \ruledhbox to\mytexdimension{\the\mytexdimension}
>
> \stoptext
>
> -----------------------------------------------------------------
>                                           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
> -----------------------------------------------------------------
>

___________________________________________________________________________________
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
___________________________________________________________________________________


  reply	other threads:[~2012-08-22 11:24 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-22  7:19 Jaroslav Hajtmar
2012-08-22  7:43 ` Wolfgang Schuster
2012-08-22  9:09   ` Jaroslav Hajtmar
2012-08-22 10:32     ` Hans Hagen
2012-08-22 11:24       ` Jaroslav Hajtmar [this message]
2012-08-22 12:12         ` Hans Hagen
2012-08-22 19:47           ` Jaroslav Hajtmar
2012-08-22 10:34     ` Peter Münster

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=5034C169.5080606@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).