ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* \doif... and Lua
@ 2011-03-25 12:04 Procházka Lukáš Ing. - Pontex s. r. o.
  2011-03-25 12:25 ` Wolfgang Schuster
  0 siblings, 1 reply; 3+ messages in thread
From: Procházka Lukáš Ing. - Pontex s. r. o. @ 2011-03-25 12:04 UTC (permalink / raw)
  To: ConTeXt

Hello,

is it possible to use a block of context code depending on a value of a Lua variable?

I tried something like:

---
\starttext
   \directlua{test = true}
   %\directlua{test = 5}
   %\directlua{test = "a"}

   \doifempty{\directlua{return test}}
   %\doifempty{\directlua{test}}
     {Yes}
     {No}
\stoptext
---

But this gives me always "No".

- I'm not sure if this is a good way, and whether attempt to use \doif(...) macro is a good idea at all.

Any (better) solution?

Best regards,

Lukas


-- 
Ing. Lukáš Procházka [mailto:LPr@pontex.cz]
Pontex s. r. o.      [mailto:pontex@pontex.cz] [http://www.pontex.cz]
Bezová 1658
147 14 Praha 4

Tel: +420 244 062 238
Fax: +420 244 461 038

___________________________________________________________________________________
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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: \doif... and Lua
  2011-03-25 12:04 \doif... and Lua Procházka Lukáš Ing. - Pontex s. r. o.
@ 2011-03-25 12:25 ` Wolfgang Schuster
  2011-03-25 13:24   ` Procházka Lukáš Ing. - Pontex s. r. o.
  0 siblings, 1 reply; 3+ messages in thread
From: Wolfgang Schuster @ 2011-03-25 12:25 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 25.03.2011 um 13:04 schrieb Procházka Lukáš Ing. - Pontex s. r. o.:

> Hello,
> 
> is it possible to use a block of context code depending on a value of a Lua variable?
> 
> I tried something like:
> 
> ---
> \starttext
>  \directlua{test = true}
>  %\directlua{test = 5}
>  %\directlua{test = "a"}
> 
>  \doifempty{\directlua{return test}}
>  %\doifempty{\directlua{test}}
>    {Yes}
>    {No}
> \stoptext
> ---
> 
> But this gives me always "No".
> 
> - I'm not sure if this is a good way, and whether attempt to use \doif(...) macro is a good idea at all.
> 
> Any (better) solution?


\starttext

\ctxlua{test = true}

Test is \ctxlua{commands.testcase(test)}{True}{False}.

\ctxlua{test = false}

Test is \ctxlua{commands.testcase(test)}{True}{False}.

\stoptext

Wolfgang

___________________________________________________________________________________
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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: \doif... and Lua
  2011-03-25 12:25 ` Wolfgang Schuster
@ 2011-03-25 13:24   ` Procházka Lukáš Ing. - Pontex s. r. o.
  0 siblings, 0 replies; 3+ messages in thread
From: Procházka Lukáš Ing. - Pontex s. r. o. @ 2011-03-25 13:24 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Perfect, thanks.

Lukas


On Fri, 25 Mar 2011 13:25:52 +0100, Wolfgang Schuster <schuster.wolfgang@googlemail.com> wrote:

>
> Am 25.03.2011 um 13:04 schrieb Procházka Lukáš Ing. - Pontex s. r. o.:
>
>> Hello,
>>
>> is it possible to use a block of context code depending on a value of a Lua variable?
>>
>> I tried something like:
>>
>> ---
>> \starttext
>>  \directlua{test = true}
>>  %\directlua{test = 5}
>>  %\directlua{test = "a"}
>>
>>  \doifempty{\directlua{return test}}
>>  %\doifempty{\directlua{test}}
>>    {Yes}
>>    {No}
>> \stoptext
>> ---
>>
>> But this gives me always "No".
>>
>> - I'm not sure if this is a good way, and whether attempt to use \doif(...) macro is a good idea at all.
>>
>> Any (better) solution?
>
>
> \starttext
>
> \ctxlua{test = true}
>
> Test is \ctxlua{commands.testcase(test)}{True}{False}.
>
> \ctxlua{test = false}
>
> Test is \ctxlua{commands.testcase(test)}{True}{False}.
>
> \stoptext
>
> Wolfgang

___________________________________________________________________________________
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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-03-25 13:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-25 12:04 \doif... and Lua Procházka Lukáš Ing. - Pontex s. r. o.
2011-03-25 12:25 ` Wolfgang Schuster
2011-03-25 13:24   ` Procházka Lukáš Ing. - Pontex s. r. o.

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).