ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Last version standalone ConTeXt issue.
@ 2016-02-09 12:28 Jaroslav Hajtmar
  2016-02-09 18:50 ` Hans Hagen
  0 siblings, 1 reply; 4+ messages in thread
From: Jaroslav Hajtmar @ 2016-02-09 12:28 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hello ConTeXist.

In the latest version ConTeXt it stopped working my macros which 
contents function  he once advised me Taco. It is low level lua code. 
Can anyone advise me what the problem is, eventually. how to replace Lua 
code in my function to make it work again? Macros worked at least 6 
years and now crashes.

Here is my function:

function thirddata.handlecsv.texmacroisdefined(macroname) -- check 
whether macroname macro is defined  in ConTeXt
-- function is used to test whether the user has defined the macro 
\macroname. If not, it needs to define any default value
     if token.csname_name(token.create(macroname)) == macroname then
         return true
      else
         return false
     end
end

Is there any alternative (ConTeXt like), which is should be possible use 
in Lua code?

Thanx
Jaroslav Hajtmar


___________________________________________________________________________________
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] 4+ messages in thread

* Re: Last version standalone ConTeXt issue.
  2016-02-09 12:28 Last version standalone ConTeXt issue Jaroslav Hajtmar
@ 2016-02-09 18:50 ` Hans Hagen
  2016-02-09 19:37   ` Jaroslav Hajtmar
  2016-10-10  9:48   ` Meer, Hans van der
  0 siblings, 2 replies; 4+ messages in thread
From: Hans Hagen @ 2016-02-09 18:50 UTC (permalink / raw)
  To: ntg-context

On 2/9/2016 1:28 PM, Jaroslav Hajtmar wrote:
> Hello ConTeXist.
>
> In the latest version ConTeXt it stopped working my macros which
> contents function  he once advised me Taco. It is low level lua code.
> Can anyone advise me what the problem is, eventually. how to replace Lua
> code in my function to make it work again? Macros worked at least 6
> years and now crashes.
>
> Here is my function:
>
> function thirddata.handlecsv.texmacroisdefined(macroname) -- check
> whether macroname macro is defined  in ConTeXt
> -- function is used to test whether the user has defined the macro
> \macroname. If not, it needs to define any default value
>      if token.csname_name(token.create(macroname)) == macroname then
>          return true
>       else
>          return false
>      end
> end
>
> Is there any alternative (ConTeXt like), which is should be possible use
> in Lua code?

\starttext

\startluacode

function interfaces.defined(name)
     return token.get_cmdname(token.create(name)) ~= "undefined_cs"
end

if interfaces.defined("foo") then
     context("foo")
else
     interfaces.setmacro("foo","bar")
end

\stopluacode

\foo

\stoptext

I'll add interfaces.defined to the core.

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
       tel: 038 477 53 69 | 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
___________________________________________________________________________________

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

* Re: Last version standalone ConTeXt issue.
  2016-02-09 18:50 ` Hans Hagen
@ 2016-02-09 19:37   ` Jaroslav Hajtmar
  2016-10-10  9:48   ` Meer, Hans van der
  1 sibling, 0 replies; 4+ messages in thread
From: Jaroslav Hajtmar @ 2016-02-09 19:37 UTC (permalink / raw)
  To: ntg-context

Thanx Hans.
Great! It works fine now! For me it is very useful and important macro.
One more thanx for reply.

Jaroslav Hajtmar



Dne 09.02.16 v 19:50 Hans Hagen napsal(a):
> On 2/9/2016 1:28 PM, Jaroslav Hajtmar wrote:
>> Hello ConTeXist.
>>
>> In the latest version ConTeXt it stopped working my macros which
>> contents function  he once advised me Taco. It is low level lua code.
>> Can anyone advise me what the problem is, eventually. how to replace Lua
>> code in my function to make it work again? Macros worked at least 6
>> years and now crashes.
>>
>> Here is my function:
>>
>> function thirddata.handlecsv.texmacroisdefined(macroname) -- check
>> whether macroname macro is defined  in ConTeXt
>> -- function is used to test whether the user has defined the macro
>> \macroname. If not, it needs to define any default value
>>      if token.csname_name(token.create(macroname)) == macroname then
>>          return true
>>       else
>>          return false
>>      end
>> end
>>
>> Is there any alternative (ConTeXt like), which is should be possible use
>> in Lua code?
>
> \starttext
>
> \startluacode
>
> function interfaces.defined(name)
>     return token.get_cmdname(token.create(name)) ~= "undefined_cs"
> end
>
> if interfaces.defined("foo") then
>     context("foo")
> else
>     interfaces.setmacro("foo","bar")
> end
>
> \stopluacode
>
> \foo
>
> \stoptext
>
> I'll add interfaces.defined to the core.
>
> -----------------------------------------------------------------
>                                           Hans Hagen | PRAGMA ADE
>               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
>       tel: 038 477 53 69 | 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
> ___________________________________________________________________________________

___________________________________________________________________________________
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] 4+ messages in thread

* Re: Last version standalone ConTeXt issue.
  2016-02-09 18:50 ` Hans Hagen
  2016-02-09 19:37   ` Jaroslav Hajtmar
@ 2016-10-10  9:48   ` Meer, Hans van der
  1 sibling, 0 replies; 4+ messages in thread
From: Meer, Hans van der @ 2016-10-10  9:48 UTC (permalink / raw)
  To: NTG ConTeXt


[-- Attachment #1.1: Type: text/plain, Size: 1642 bytes --]

This is an interesting feature for handling a call to an undefined macro (as might result from \csnam#1\endcsname, for example.

>
> \starttext
>
> \startluacode
>
> function interfaces.defined(name)
>    return token.get_cmdname(token.create(name)) ~= "undefined_cs"
> end
>
> if interfaces.defined("foo") then
>    context("foo")
> else
>    interfaces.setmacro("foo","bar")
> end
>
> \stopluacode
>
> \foo
>
> \stoptext
>
> I'll add interfaces.defined to the core.
>
> -----------------------------------------------------------------
>                                          Hans Hagen | PRAGMA ADE
>              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
>      tel: 038 477 53 69 | www.pragma-ade.com<http://www.pragma-ade.com> | www.pragma-pod.nl<http://www.pragma-pod.nl>
> -----------------------------------------------------------------

As an example I executed the following code:

\starttext
\framed{\ConTeXt-version = \contextversion}\blank

\def\nofoo{This is nofoo}
\startluacode
if interfaces.defined("foo") then
   context("foo")
else
   interfaces.setmacro("foo","nofoo")
end
\stopluacode
\tex{foo} is undefined: "\foo"\crlf
\def\foo{This is foo}
\tex{foo} is defined: "\foo"\crlf
\stoptext

The result of the first call to \foo, however, is not "This is nofoo" but the name of the nofoo macro. I expected that \nofoo would have been executed instead. That would have been beneficial, because the missing macro \foo can then be substituted for something the programmer thinks useful.
Is this correct? Or am I doing something wrong?

Hans van der Meer




[-- Attachment #1.2: Type: text/html, Size: 2843 bytes --]

[-- Attachment #2: tester.pdf --]
[-- Type: application/pdf, Size: 8793 bytes --]

[-- Attachment #3: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
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] 4+ messages in thread

end of thread, other threads:[~2016-10-10  9:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-09 12:28 Last version standalone ConTeXt issue Jaroslav Hajtmar
2016-02-09 18:50 ` Hans Hagen
2016-02-09 19:37   ` Jaroslav Hajtmar
2016-10-10  9:48   ` Meer, Hans van der

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).