Thanks, but I'm not able to run this code in my system. I'm working in ConTeXt ver: 2014.12.06 14:20 MKIV beta fmt: 2014.12.8 int: english/english and the error message is: >> runscript ! Isolated expression. ( mlib_luas_luacall->begingroup.runscript( ""for.s=(TEXT2):if.string.s:&s.elsei... lua->..._s,(TEXT3))else:mlib_luas_luacall((TEXT3)) fi.endgroup <*> ...lua("mp.print(#document.variables.labels)") : b[i] = unitsquare xscal... ! Extra tokens will be flushed. ( mlib_luas_luacall->begingroup.runscript( ""for.s=(TEXT2):if.string.s:&s.elsei... lua->..._s,(TEXT3))else:mlib_luas_luacall((TEXT3)) fi.endgroup <*> ...lua("mp.print(#document.variables.labels)") : b[i] = unitsquare xscal... >> vacuous ! Improper final value has been replaced by 0. : <*> ...a("mp.print(#document.variables.labels)") : b[i] = unitsquare xscaled... 2014-12-08 9:21 GMT+00:00 Hans Hagen : > On 12/7/2014 8:25 PM, DesdeChaves wrote: > >> >> I would like to pass the lua table keys and values to metapost. In the >> keys i have information about the paths names and in the values i have >> information about the label that should be draw in the center of each >> path (unitsquare). >> >> In my code (see attach) the table in question is >> "weekdays_number_and_name". >> >> I know that is possible to pass a array from metapost to lua. Is the >> reverse possible? >> > > it's possible to ask values from within mp: > > \starttext > > \startluacode > document.variables = { > labels = { > "one", > "two", > "three", > } > } > \stopluacode > > \startMPpage > numeric dx, dy; > dx = 4.4cm; > dy = 0.53cm; > path b[]; > for i=1 upto lua("mp.print(\#document.variables.labels)") : > b[i] = unitsquare xscaled dx yscaled dy shifted (0, (i-1)*dy); > draw b[i]; > label(lua("mp.quoted(document.variables.labels[" & decimal i & > "])"), center b[i]); > endfor > \stopMPpage > > \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 > ____________________________________________________________ > _______________________ -- Atentamente DesdeChaves