ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* \ctxlua and \startluacode ... \stopluacode
@ 2019-10-14 16:50 Rudolf Bahr
  2019-10-14 16:55 ` RE : " Joseph
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Rudolf Bahr @ 2019-10-14 16:50 UTC (permalink / raw)
  To: ntg-context


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
___________________________________________________________________________________

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

end of thread, other threads:[~2019-10-16  7:03 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-14 16:50 \ctxlua and \startluacode ... \stopluacode Rudolf Bahr
2019-10-14 16:55 ` RE : " Joseph
2019-10-14 17:08 ` Taco Hoekwater
2019-10-14 17:19 ` Hans Hagen
2019-10-14 19:07   ` Rudolf Bahr
2019-10-14 19:26     ` Taco Hoekwater
2019-10-14 22:50       ` Rudolf Bahr
2019-10-15  8:04         ` Taco Hoekwater
2019-10-15  8:15           ` Hans Hagen
2019-10-16  7:03             ` Rudolf Bahr

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