lua-users home
lua-l archive

Search lua-l

This index contains 143,615 documents and 1,774,615 keywords. Last update on 2023-03-09 .

Query: [How to search]

Display: Description: Sort by:

Results:

References: [ attempt: 3298 ] [ to (Too many documents hit. Ignored) ] [ index: 6969 ] [ a (Too many documents hit. Ignored) ] [ nil: 12751 ]

Total 504 documents matching your query.

41. Re: Suggestion: Deprecate "Attempt to index a nil value" error; instead, return nil or create table (score: 539)
Author: Diego Nehab <diego@...>
Date: Fri, 6 Mar 2020 16:24:46 -0300
Ah, the thread has been broken a couple times. Apologies. I would have replied to it instead. Is this the message you mean?    http://lua-users.org/lists/lua-l/2020-03/msg00017.html Anyway, the point
42. Re: Suggestion: Deprecate "Attempt to index a nil value" error; instead, return nil or create table (score: 539)
Author: Luiz Henrique de Figueiredo <lhf@...>
Date: Wed, 4 Mar 2020 06:42:42 -0300
You can avoid special fields like that by using a separate table for private attributes: local Sparse = {} local Attr = setmetatable({}, {__mode = ?k?}) local function new(dimension) local sparse =
43. Re: [5.1.4] "attempt to index global 'data' (a nil value) (score: 461)
Author: "Xu, Gang L" <gang.l.xu@...>
Date: Sun, 24 Jul 2011 15:25:03 -0400
D[ 'data' is nil because io.open returns nil on failure. I would suggest the following first line: data = assert(io.open([[C:\places.txt]],"r")) Note two things: 1) The call to assert to raise any er
44. RE: [5.1.4] "attempt to index global 'data' (a nil value) (score: 454)
Author: Dave Collins <Dave.Collins@...>
Date: Tue, 26 Jul 2011 15:59:41 -0400
Sorry, I see the other responses now. This got trapped as spam so it stuck out as a singleton post. (Trying to contribute back the the community that's been so much help) Dave Collins Hello Using a
45. RE: [5.1.4] "attempt to index global 'data' (a nil value) (score: 454)
Author: Dave Collins <Dave.Collins@...>
Date: Tue, 26 Jul 2011 15:55:55 -0400
I'm pretty new but it looks like no one's responded. It seems to me what you want to do is this: local data = assert(io.open("C:\places.txt","r")) if (data) then for line in data:lines() do ... else
46. Re: [5.1.4/newbie] "attempt to index ... 'file' (a nil value)"? (score: 454)
Author: "Patrick Mc(avery" <spell_gooder_now@...>
Date: Fri, 18 Feb 2011 06:49:14 -0500
I'm trying to create a text file, and google for samples on how to do this, but regardless of using a global or local variable to hold the file descriptor, I get the following error: "attempt to inde
47. [5.1.4/newbie] "attempt to index ... 'file' (a nil value)"? (score: 454)
Author: Gilles Ganault <gilles.ganault@...>
Date: Fri, 18 Feb 2011 12:53:42 +0100
Hello I'm trying to create a text file, and google for samples on how to do this, but regardless of using a global or local variable to hold the file descriptor, I get the following error: "attempt t
48. Re: [5.1.4] "attempt to index global 'data' (a nil value) (score: 448)
Author: Peter Cawley <lua@...>
Date: Sun, 24 Jul 2011 14:03:32 +0100
'data' is nil because io.open returns nil on failure. I would suggest the following first line: data = assert(io.open([[C:\places.txt]],"r")) Note two things: 1) The call to assert to raise any error
49. Re: ERROR: lua: simpleApp1.lua:1: attempt to index global 'fltk' (a nil value) (score: 445)
Author: Patrick Rapin <toupie300@...>
Date: Wed, 22 Dec 2010 20:39:14 +0100
Maybe that the script you are quoting has been written for murgaLua [1], a Lua distribution with a built-in FLTK binding. I have tried that code with the Windows murgaLua 0.6.8 executable and it work
50. [5.1.4] "attempt to index global 'data' (a nil value) (score: 441)
Author: Gilles Ganault <gilles.ganault@...>
Date: Sun, 24 Jul 2011 14:56:24 +0200
Hello Using a Lua script on XP, I need to open an HTML file and extract hyperlinks... == data = io.open("C:\places.txt","r") for line in data:lines() do for token in string.gmatch(line, '<a href="(/p
51. Re: ERROR: lua: simpleApp1.lua:1: attempt to index global 'fltk' (a nil value) (score: 441)
Author: HyperHacker <hyperhacker@...>
Date: Tue, 21 Dec 2010 18:50:18 -0700
Well you haven't included the fltk module. The '#' is a bit worrisome too; are you running this as root? -- Sent from my toaster.
52. ERROR: lua: simpleApp1.lua:1: attempt to index global 'fltk' (a nil value) (score: 441)
Author: Shamun toha md <shamun.toha@...>
Date: Wed, 22 Dec 2010 01:59:32 +0100
stack traceback: simpleApp1.lua:1: in main chunk [C]: ? #  $ cat simpleApp1.lua    do local object = fltk:Fl_Double_Window(166, 165, "My App");     window = object;     fltk:Fl_Return_Button(5, 130,
53. Re: [5.1.4/newbie] "attempt to index ... 'file' (a nil value)"? (score: 440)
Author: Andrew Wilson <agrwagrw@...>
Date: Fri, 18 Feb 2011 09:03:03 -0500
-- slight typo don't forget table parameter in index.. do local mt = getmetatable(_G) or {} mt.__index = function(t,k) error("Global "..k.." does not exist", 2) end setmetatable(_G, mt) end n1="strin
54. Re: [5.1.4/newbie] "attempt to index ... 'file' (a nil value)"? (score: 436)
Author: Axel Kittenberger <axkibe@...>
Date: Fri, 18 Feb 2011 15:19:11 +0100
Chap. 14.2 in the book does, but it doesn't mention etc/strict.lua, didn't notice a forward link in the errors chap. Would be a good idea for that cookbook :)
55. Re: [5.1.4/newbie] "attempt to index ... 'file' (a nil value)"? (score: 436)
Author: Gilles Ganault <gilles.ganault@...>
Date: Fri, 18 Feb 2011 15:09:24 +0100
Speaking of which, is there a good article/tutorial/chapter for newbies on debugging Lua scripts, besides Chapter 8 in the PiL? www.lua.org/pil/index.html#8 The online PiL is from 2004, and doesn't m
56. Re: [5.1.4/newbie] "attempt to index ... 'file' (a nil value)"? (score: 436)
Author: Axel Kittenberger <axkibe@...>
Date: Fri, 18 Feb 2011 14:53:25 +0100
Best is to add a metatable to globals _G that errors on index. Put this on top of your program. do local mt = getmetatable(_G) or {} mt.__index = function(k) error("Global "..k.." does not exist", 2
57. Re: [5.1.4/newbie] "attempt to index ... 'file' (a nil value)"? (score: 432)
Author: Michal Kottman <k0mpjut0r@...>
Date: Fri, 18 Feb 2011 21:31:07 +0100
__index and __newindex always receive the table as the first argument (see http://www.lua.org/manual/5.1/manual.html#2.8 and http://www.lua.org/pil/13.4.1.html ). So the correct signature should be:
58. Re: [5.1.4/newbie] "attempt to index ... 'file' (a nil value)"? (score: 432)
Author: Steve Litt <slitt@...>
Date: Fri, 18 Feb 2011 14:32:33 -0500
Axel, This is wonderful. It's like "use strict" for Lua. However, I had a problem with your code because k was always a table, regardless of the global I read or wrote (I also added a __newindex() to
59. Re: [5.1.4/newbie] "attempt to index ... 'file' (a nil value)"? (score: 432)
Author: Luiz Henrique de Figueiredo <lhf@...>
Date: Fri, 18 Feb 2011 11:59:32 -0200
See also etc/strict.lua which does this and more.
60. Re: [5.1.4/newbie] "attempt to index ... 'file' (a nil value)"? (score: 432)
Author: Gilles Ganault <gilles.ganault@...>
Date: Fri, 18 Feb 2011 14:56:57 +0100
Thanks Axel. I'll give it a try.

Search by Namazu v2.0.21