On 11/19/2019 8:34 PM, Rudolf Bahr wrote:
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.
nearly always context is th emaster (it is anyway as it manages the process)
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.
can be done in tex of lua
- 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.
that can be done runtime ...
- To estimate the shift amount of all columns together in order to horizontally get them centered on the page.
can be done by tex or lua
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.
you can store info in the tuc file (there are examplex on the wiki and in the test suite) or you cam create a table, save it at the end of the run and load it at the start (assuming that you cannot just recalculate the values each run, but i assume that you have a reason for not doing that)
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.
if each page can be recognized you can make a hash of its properties and store the page specific data using that hash
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.
unrelated Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------