ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Rudolf Bahr <quasi@quasi.de>
To: ntg-context@ntg.nl
Subject: Re: "error not related to input file"
Date: Mon, 16 Dec 2019 21:03:29 +0100	[thread overview]
Message-ID: <20191216200329.GA3893@nan> (raw)
In-Reply-To: <57670e8a-9ffa-a6b4-f425-220b3bd171e4@xs4all.nl>

[-- Attachment #1: Type: text/plain, Size: 3903 bytes --]

On Sat, Dec 14, 2019 at 10:31:20PM +0100, Hans Hagen wrote:
> On 12/14/2019 5:43 PM, Rudolf Bahr wrote:
> > 
> > Hello All,
> > 
> > In:
> > LuaMetaTeX, Version 2.03.3
> > ConTeXt  ver: 2019.12.12 19:35 MKIV beta  fmt: 2019.12.12  int: english/english
> > I get the following error message:
> > 
> > tex error       > error not related to input file:
> > tex error       >   tex: ! Emergency stop
> > tex error       >   lua: ?
> > tex error       >   mps: -
> >
> > In LuaTeX ... I get a "*" instead of the error message above.
> > And again my program does all what it should, but a grey pdf-page too.
> >
> > Sorry, no MWE available.


On Sat, Dec 14, 2019 at 07:27:34PM +0100, Otared Kavian wrote:
> 
> Since I have also suffered somewhat from the cryptic (and often useless…) error messages, I understand your frustration :-)
> Now, maybe if you do 
> 	context --directives="system.showerror" myfile.tex
> then you get a file named « myfile-status.html » which is more helpful.


On Sat, Dec 14, 2019 at 10:31:20PM +0100, Hans Hagen wrote:
>
> normally an * means: waiting for input .... and no message is then involved
> as in principle there is no real error, apart from waiting for input


Otared and Hans, thank you for your answers and Otared especially for your
sympathy! :-)

In the meantime I could get rid of "! Emergency stop" and "*" by changing
a \def-command which calls a luacode subprogram; see further down in my MWE.

My program run now looks essentially better, but "--directives="system.showerror" 
and "<my program>-status.html" still report an error: "! Undefined control sequence"
without telling which control sequence is undefined. How reliable is this error
message? I don't know of control sequences in luacode or what does this error message
mean?

Here is a MWE which shows my program structure. Sorry, this MWE works really :-)
During my attempts to find the error I got for a short time the message: "Invalid
\starttext ... \stoptext structure" which I don't understand.

--------------------------------------------------- MWE -------------------------------
\def\projectpath{/home/sam/trip-2019/}

\startluacode
   userdata = userdata or {}
   u = userdata

   function u.table_save ( tab, file )
      local tab   = tab
      local file  = file

      dofile ("table_save_u_table_load.lua")
      table.save(tab, file)
   end


   function u.Init ( col )

      local col  = col 
      local ppth = tokens.getters.macro("projectpath")
      local xO   = tokens.getters.macro("xO")
      local yO   = tokens.getters.macro("yO")

      local I = {}	-- Table of initial values
      I ["projectpath"] = ppth
      I ["column"]      = {}
      I ["column"][col] = {}
      I ["column"][col]["layerpos"] = {}
      I ["column"][col]["layerpos"] ["xO"] = xO
      I ["column"][col]["layerpos"] ["yO"] = yO

      u.table_save(I,"I-Table.lua") 
   end
   
\stopluacode

%\def\Init #1 {\ctxlua {u.Init ([==[#1]==]) }}% --the blanks produced my "! Emergency stop"
\def\Init#1{\ctxlua{u.Init([==[#1]==])}}%       --in this form the command works 

\starttext
   \def\Column{A}%
   \def\xO{0}%  in pt
   \def\yO{20}% in pt

   \Init{\Column}%%
\stoptext
---------------------------------------------------------------------------------------
For those possibly interested in running this MWE I append "table_save_u_table_load.lua",
a lua program to save and reload lua tables, found in the lua homepage. Anyway, the
resulting flattened table "I" is here:

return {
-- Table: {1}
{
   ["column"]={2},
   ["projectpath"]="/home/sam/trip-2019/",
},
-- Table: {2}
{
   ["A"]={3},
},
-- Table: {3}
{
   ["layerpos"]={4},
},
-- Table: {4}
{
   ["yO"]="20",
   ["xO"]="0",
},
}



I think nobody will be able to help me in this case, I myself have to try again and 
again to finally find the error. If so, this would be the nicest christmas gift to me :-)

Best regards,

Rudolf

[-- Attachment #2: table_save_u_table_load.lua --]
[-- Type: text/plain, Size: 3730 bytes --]



--[[
	Save Table to File
	Load Table from File
	v 1.0
	
	Lua 5.2 compatible
	
	Only Saves Tables, Numbers and Strings
	Insides Table References are saved
	Does not save Userdata, Metatables, Functions and indices of these
	----------------------------------------------------
	table.save( table , filename )
	
	on failure: returns an error msg
	
	----------------------------------------------------
	table.load( filename or stringtable )
	
	Loads a table that has been saved via the table.save function
	
	on success: returns a previously saved table
	on failure: returns as second argument an error msg
	----------------------------------------------------
	
	Licensed under the same terms as Lua itself.
]]--
do
	-- declare local variables
	--// exportstring( string )
	--// returns a "Lua" portable version of the string
	local function exportstring( s )
		return string.format("%q", s)
	end

	--// The Save Function
	function table.save(  tbl,filename )
		local charS,charE = "   ","\n"
		local file,err = io.open( filename, "wb" )
		if err then return err end

		-- initiate variables for save procedure
		local tables,lookup = { tbl },{ [tbl] = 1 }
		file:write( "return {"..charE )

		for idx,t in ipairs( tables ) do
			file:write( "-- Table: {"..idx.."}"..charE )
			file:write( "{"..charE )
			local thandled = {}

			for i,v in ipairs( t ) do
				thandled[i] = true
				local stype = type( v )
				-- only handle value
				if stype == "table" then
					if not lookup[v] then
						table.insert( tables, v )
						lookup[v] = #tables
					end
					file:write( charS.."{"..lookup[v].."},"..charE )
				elseif stype == "string" then
					file:write(  charS..exportstring( v )..","..charE )
				elseif stype == "number" then
					file:write(  charS..tostring( v )..","..charE )
				end
			end

			for i,v in pairs( t ) do
				-- escape handled values
				if (not thandled[i]) then
				
					local str = ""
					local stype = type( i )
					-- handle index
					if stype == "table" then
						if not lookup[i] then
							table.insert( tables,i )
							lookup[i] = #tables
						end
						str = charS.."[{"..lookup[i].."}]="
					elseif stype == "string" then
						str = charS.."["..exportstring( i ).."]="
					elseif stype == "number" then
						str = charS.."["..tostring( i ).."]="
					end
				
					if str ~= "" then
						stype = type( v )
						-- handle value
						if stype == "table" then
							if not lookup[v] then
								table.insert( tables,v )
								lookup[v] = #tables
							end
							file:write( str.."{"..lookup[v].."},"..charE )
						elseif stype == "string" then
							file:write( str..exportstring( v )..","..charE )
						elseif stype == "number" then
							file:write( str..tostring( v )..","..charE )
						end
					end
				end
			end
			file:write( "},"..charE )
		end
		file:write( "}" )
		file:close()
	end
	
	--// The Load Function
	function table.load( sfile )

           local ftables,err = loadfile( sfile )
		if err then return _,err end
		local tables = ftables()
		for idx = 1,#tables do
			local tolinki = {}
			for i,v in pairs( tables[idx] ) do
				if type( v ) == "table" then
					tables[idx][i] = tables[v[1]]
				end
				if type( i ) == "table" and tables[i[1]] then
					table.insert( tolinki,{ i,tables[i[1]] } )
				end
			end
			-- link indices
			for _,v in ipairs( tolinki ) do
				tables[idx][v[2]],tables[idx][v[1]] =  tables[idx][v[1]],nil
			end
		end
		return tables[1]
	end
-- close do
end


do
   local function file_exists(name)
      local f=io.open(name,"r")
      if f~=nil then io.close(f) return true else return false end
   end
end


--return {

--   table.save  = table.save,
--   table.load  = table.load,
--   file_exists = file_exists,
--}



[-- Attachment #3: Type: text/plain, Size: 493 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

      reply	other threads:[~2019-12-16 20:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-14 16:43 Rudolf Bahr
2019-12-14 16:57 ` Rudolf Bahr
2019-12-14 18:27   ` Otared Kavian
2019-12-14 21:31 ` Hans Hagen
2019-12-16 20:03   ` Rudolf Bahr [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191216200329.GA3893@nan \
    --to=quasi@quasi.de \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).