[NTG-context] Exchangeing content of variables between luacode and context

Rudolf Bahr quasi at quasi.de
Tue Nov 19 20:34:26 CET 2019


On Tue, Nov 19, 2019 at 04:55:15PM +0100, Wolfgang Schuster wrote:
> 
> Can you make a minimal example of your actual problem.


No, sorry, I can't.

My 'actual problem' is more or less a design problem: Should in a book project
ConTeXt be the master and Luacode the slave or vice versa? Both seems possible.

The task to solve is to set a photo album with say 300 DIN A4 landscape pages.
On every page there should be 1 to 4 columns filled with photos and texts mostly
defined in layers.

Up to now I made all in ConTeXt manually by trying, for instance::
- To estimate the width of layers, if neighboured layers should contain photos of
  same height with respect to center horizontally all columns at end of page.
- To complete abbreviations of long picture names; it's rather annoying doing
  this by copy and paste with hundreds of photo names; instead I'd like to type
  a short code and Luacode should complete it to the full name.
- To estimate the shift amount of all columns together in order to horizontally
  get them centered on the page.

All of these tasks can be made best by Luacode functions. And I'd like to save
their results in the ConTeXt program permanently. With 'tokens.setters.macro()'
it's possible only in the same, Luacode calling ConTeXt run. In the following
run, the macro shows its original value again and the Luacode program must be
called again to alter it.

So I've to think about making Luacode the master and ConTeXt the slave. Then it'd
be possible to embody Luacode's results permanently in the ConTeXt code. Vice versa
a solution could be to store Luacode's results in a flattened Lua table on disc.
But the perfect relating to their ConTeXt page remains difficult when inserting
or deleting of pages in an ensemble of 300 pages should become necessary. Another
much simpler solution would be the proposal above, namely, to copy the ConTeXt
program step by step and page by page to another file and introducing the Luacode
results simultaneously. 

In [1] there is a chapter with "stepper" commands, but I didn't understand that,
so I can't say, whether they are suitable for this issue.

Rudolf

[1] Hans Hagen, "ConTeXt Lua Documents", January 12, 2018, 3.4, page 30


More information about the ntg-context mailing list