# [NTG-context] Accessing string contents of a macro in Lua.

luigi scarso luigi.scarso at gmail.com
Wed Apr 24 18:50:19 CEST 2013

On Wed, Apr 24, 2013 at 5:51 PM, Sietse Brouwer <sbbrouwer at gmail.com> wrote:
> Hi all,
>
> Below are three methods of defining a dimension / dimension string in
> ConTeXt --- the first two boil down to storing a string in a macro,
> the last is a proper TeX dimen. I want to access these dimensions from
> Lua.
>
> I can access the dimen via tex.dimen.ColumnC, but how can I access the
> macro contents?
> If there is no solution, I can always explicitly pass the value to Lua with
>
>     \ctxlua{var = '\measure{ColumnA}'}
>
> , but I want to know if there is a Lua-only method to get these values.
>
> %% MWE
> \definemeasure[ColumnA][10mm]
>
> \def\ColumnB{20mm}

not a general solution
%%%
\def\ColumnB{20mm}

\starttext
\startluacode
local c = "\\csname ColumnB\\endcsname"
context("ColumnB=%s",c)
\stopluacode

\par
\toks0=\expandafter{\ColumnB}
\startluacode
context("ColumnB=%s",tex.toks[0])
\stopluacode

\stoptext

--
luigi