[NTG-context] Testing non-existent counter in Lua

Taco Hoekwater taco at elvenkind.com
Tue Jun 22 07:55:31 CEST 2010


Jaroslav Hajtmar wrote:
> Hi, all.
> 
> How do I know (due Lua) that the counter has not been defined in ConTeXt 
> (through the command newcount)?
> 
> I am trying testing :
> 
> if tex.count.mycount == nil then...
> 
> or
> 
> if tex.count.mycount == 'error' then...
> 
> then when counter isnt defined due \newcount\mycount, then test ending 
> with error message.
> 
> When counter is defined due
> \newcount\mycount,
> \mycount=1
> 
> then test
> if tex.count.mycount == 1 then...

if token.command_name(token.create('mycount')) == 'assign_int'
    and tex.count.mycount == 1 then
    ...
end

Best wishes,
Taco



More information about the ntg-context mailing list