lua libs v0.5 - LUA Scripting - CHDK Forum

lua libs v0.5

  • 14 Replies
  • 14291 Views
lua libs v0.5
« on: 11 / March / 2009, 18:04:25 »
Advertisements
here's the first release of lua libs. i've tried to generalize the solutions to problems i've encountered in my own scripting projects. I spent a good deal of time debugging problems with my script which used 6 libs but i'm not certain that i ironed out all the bugs. i get errors without text on occasion if i use all of them but the ones uploaded here seem to work fine. if you experience this problem, you might consider adding the lib code directly to your script.

enjoy!

*

Offline PhyrePhoX

  • *****
  • 2254
  • make RAW not WAR
    • PhyreWorX
Re: lua libs v0.5
« Reply #1 on: 14 / March / 2009, 20:22:44 »
stickified.

havent checked it out myself yet, as i am not using lua that much and actually su*k at coding it :D

this message was brought to you by gorilla glue, the certified glue for board admins.


Re: lua libs v0.5
« Reply #2 on: 05 / April / 2009, 16:21:11 »
version v0.6

Re: lua libs v0.5
« Reply #3 on: 13 / May / 2009, 12:30:48 »
version v0.7

*

Offline Mac

  • *
  • 40
Re: lua libs v0.5
« Reply #4 on: 01 / June / 2009, 14:28:36 »

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: lua libs v0.5
« Reply #5 on: 02 / June / 2009, 15:53:05 »
Actually I wrote that one and I'm definitely not expert in Lua, hardly know the language.

Anyway, I have no clue if it's a good idea to go opening 1000 files in a row and not closing them (or if opening a new file to the same handle (or whatever) closes the previous one).

That long loop comment means that Lua might not yield during the loop (often enough or at all), which means that if there are 1000 files it could take some time before Lua passes control to to other stuff, which could potentially (such as with the very slow&tiny MMC cards that come with Canon cameras) cause weirdness in some situations.

*

Offline reyalp

  • ******
  • 14138
Re: lua libs v0.5
« Reply #6 on: 02 / June / 2009, 19:31:04 »
Anyway, I have no clue if it's a good idea to go opening 1000 files in a row and not closing them (or if opening a new file to the same handle (or whatever) closes the previous one).
If they stayed open, you'd run out of filehandles and/or memory quite quickly.

File objects that go out of scope or become unreferenced should get closed eventually in the garbage collection process, but it's possible you would run out of something before that happened. I suggest explicitly closing any files you open as soon as you are done with them. In cases where you might be writing to the file, this also ensures the output is flushed.

os.stat (as the original code does) is probably preferable to opening/closing.

I also suggest using string.format to construct file names, rather than concatenation and tostring.

Don't forget what the H stands for.

*

Offline Mac

  • *
  • 40
Re: lua libs v0.5
« Reply #7 on: 03 / June / 2009, 18:02:55 »
Good points!
Thanks for the helpful pointers.
Much appreciated.

*

Offline Mac

  • *
  • 40
Re: lua libs v0.5
« Reply #8 on: 03 / June / 2009, 18:26:24 »
This brings up a recurring problem with CHDK - not having complete documentation.
Lau 5.1 does recognize os.stat.
Is there any place where all the features available in CHDK's version of Lua are listed (explained)?

*

Offline Mac

  • *
  • 40
Re: lua libs v0.5
« Reply #9 on: 03 / June / 2009, 18:33:38 »
Sorry all.
Should learn to do a shearch first before posting.
Found the site documentin os.stat
My bad!

 

Related Topics


SimplePortal © 2008-2014, SimplePortal