dofile() & sleep() - Script Writing - CHDK Forum

dofile() & sleep()

  • 2 Replies
  • 1859 Views
*

Offline msl

  • *****
  • 1274
  • A720 IS, SX220 HS 1.01a
    • CHDK-DE links
dofile() & sleep()
« on: 10 / February / 2013, 17:49:09 »
Advertisements
I'm planning a bigger script project with several script parts. My idea is to start another skript with dofile(). First tests are ok.

But there is an issue with dofile() and sleep(). When a script runs via dofile() and in this script is included sleep(), I get an error message. Without sleep() is all fine.

example scripts:
Code: (lua) [Select]
--[[
@title test1
]]

for i=1, 10 do
    print("test", i)
    sleep(500)
    print(get_meminfo().free_size)
end
Code: (lua) [Select]
--[[
@title test2
]]

dofile("A/CHDK/SCRIPTS/t_01.lua")
Error message:
Code: [Select]
attempt to yield across metamethod/C-call boundary
Any thoughts?

msl
CHDK-DE:  CHDK-DE links

*

Offline reyalp

  • ******
  • 13059
Re: dofile() & sleep()
« Reply #1 on: 10 / February / 2013, 17:52:11 »
Instead of dofile, use

Code: [Select]
f=loadfile('foo.lua')
f()
or more succinctly
Code: [Select]
loadfile('foo.lua')()
Don't forget what the H stands for.

*

Offline msl

  • *****
  • 1274
  • A720 IS, SX220 HS 1.01a
    • CHDK-DE links
Re: dofile() & sleep()
« Reply #2 on: 10 / February / 2013, 18:04:51 »
That was it.

Thank you very much for this fast answer.

msl
CHDK-DE:  CHDK-DE links

 

Related Topics