I suspect the double quotes are part of file names, hence files cannot be found. Perhaps try remove them in macro argument.

Hope this helps

 

De : Rudolf Bahr
Envoyé le :lundi 14 octobre 2019 18:50
À : ntg-context@ntg.nl
Objet :[NTG-context] \ctxlua and \startluacode ... \stopluacode

 

 

Dear List!

 

THis MWE must be faulty, but where is the error?

 

====================================================

 

\startluacode

 

userdata = userdata or {}

 

function userdata.file_exists (name)

 

   local name = name

   local f    = assert ( io.open ( name, "r" ))

 

   if f then

      f:close ()

      context ( name )

      context ( "  exists!" )

   else

      context ( name )

      context ( "  doesn't exist!" )

   end

  

end

 

\stopluacode

 

 

\starttext

 

\def\lookupfile#1%

                {\ctxlua{userdata.file_exists([==[#1]==])}}

 

\lookupfile{"$HOME/context-tests/AAA.lua"}    % "AAA.lua" intentionally does    exist

\lookupfile{"$HOME/context-tests/BBB.lua"}    % "BBB.lua" intentionally doesn't exist

 

\stoptext

 

====================================================

 

It makes no difference in commenting out the first or the second "\lookupfile" command.

The error message eventually is always nearly the same:

 

token call, execute: [ctxlua]:8: "$HOME/context-tests/AAA.lua": No such file or directory

token call, execute: [ctxlua]:8: "$HOME/context-tests/BBB.lua": No such file or directory

 

I'm using:

LuaMetaTeX, Version 2.00.0

ConTeXt  ver: 2019.10.10 18:15 MKIV beta  fmt: 2019.10.12  int: english/english

 

Please, any ideas?

 

Regards,

Rudolf

 

___________________________________________________________________________________

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://context.aanhet.net

archive  : https://bitbucket.org/phg/context-mirror/commits/

wiki     : http://contextgarden.net

___________________________________________________________________________________