lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I've come across a couple of linehook phenomena (in my Mac Lua 4.0b) that I need help with. My aim was to be able to abort a running script by some conditional code in a linehook function. It seems, however, that calling error() in the linehook is not aborting anything. Are there other solutions?

The other thing that puzzles me, is that when I run a script file like the one below, the linehook function doesn't kick in until the second time I run it. What might be the reason for that?

-----------------------------
--dofile("hooktest0.lua")

function lhook(n)
   print("lhook at line "..n)
   error() -- no effect here?
end
setlinehook(lhook)

print("clock = "..clock())
print("clock = "..clock())
print("clock = "..clock())
print("done")
-----------------------------

The first time I run it, I get only this:
-----------------------------
clock = 2077.35
clock = 2077.383333333333
clock = 2077.383333333333
done
-----------------------------

The second time I get this:
-----------------------------
lhook at line 6
lhook at line 7
lhook at line 9
clock = 2094.566666666667
lhook at line 10
clock = 2094.583333333333
lhook at line 11
clock = 2094.583333333333
lhook at line 12
done
-----------------------------

/Jon
---------------------------------------------------------------------------
Jon Kleiser / ADB ekstern / USIT / University of Oslo / Norway
Mail: Jon.Kleiser@usit.uio.no / Tel: +47-22 85 28 04 / Fax: +47-22 85 29 70
---------------------------------------------------------------------------