On 03/06/2018 03:29 AM, Hans Hagen wrote:
> On 3/6/2018 4:43 AM, Bruno Le Floch wrote:
>> On 03/05/2018 12:00 PM, Hans Hagen wrote:
>>> On 3/5/2018 5:08 PM, a...@linux.pl wrote:
>>>> Hello,
>>>>
>>>> Anybody know how I can set variable in tex?
>>>>
>>>> For example
>>>>
>>>> \count10=20
>>>> \def\proste{To jest prosty napis}
>>>>    a\directlua{tex.print(tex.count[10]+5)}b
>>>>    a\directlua{tex.set("\proste","Trudne")}b
>>>> \proste
>>>> \bye
>>>>
>>>> I need setup \proste definition to my own string
>>>>
>>>> How I can read TeX variable \mynumber from lua
>>>> and set variable \mynumber on TeX but set in lua script.
>>>
>>> \starttext
>>>
>>> \newcount\MyCount \MyCount = 20
>>>
>>> \def\MyMacro{To jest prosty napis}
>>>
>>> a\directlua{tex.print(tex.getcount("MyCount")+5)}b
>>>
>>> a\directlua{token.set_macro("MyMacro","Trudne")}b
>>>
>>> \MyMacro
>>>
>>> \stoptext
>>>
>>>
>>
>> Interestingly, token.set_macro allows defining macros whose replacement
>> text has unbalanced braces.
>>
>> \directlua{token.set_macro("MyMacro", "\string{")}
>> \expandafter\show\MyMacro
>> \bye
> 
> Indeed. No expansion and parsing is involved except for one level
> checking of catcodes and tokens.
> 
> This function is mostly there for simple usage like storing a string or
> so (no support for parameters etc).
> 
> A bit like:
> 
> \edef\foo{\noexpand\scantextokens{\string{}}
> \edef\oof{\noexpand\scantextokens{\string}}}
> 
> test \foo\bf bar\oof\ test
> 
> Hans
> 

Thank you for these details!
Best regards,
Bruno
_______________________________________________
dev-luatex mailing list
dev-luatex@ntg.nl
https://mailman.ntg.nl/mailman/listinfo/dev-luatex

Reply via email to