Page 1 sur 1

I recreated the io and os modules using Ndless

Message non luPosté: 03 Juil 2020, 20:39
de nspiredev500
Hi,
I don't know whether to post this in the native forum or the Lua forum, but I think it is more usefull to the Lua people.
I'm working on Lua and C interaction for the Nspire now and I thought while I'm at it, I could implement the missing Lua modules.
This means you need Ndless to use these modules.
A few functions are currently unimplemented or are unimplemented because they make no sense on the calculator.
os.exit, os.getenv and os.setlocale make no sense the way TI-Lua is implemented.
io.popen cannot be implemented because there are no pipes on the Nspire.
io.lines, io.tmpfile and os.tmpfile are not implemented by me right now.
io.read only supports reading raw bytes in up to 4K chunks.

I'll add the unsupported functions later, but it should be good for now.
To make debugging easier for me, the io functions don't return an error string, but just error. This way you can always see the error
The io library should be working, but I haven't tested it that much. It should always close files when the app is closed or the file object is garbage-collected.
If a file is already open for writing and you try to open it a second time, it will error. If you app didn't open it 2 times, then my library didn't close the file the last time.
Pressing the reset button will close all open files.

To use the libraries, install the correct Ndless version for you OS. Then transfer the io.luax.tns and os.luax.tns files to your calculator.
To use them in a script, use:
nrequire "io"
nrequire "os"

The source code is on Github.
Have fun with the Lua os and io modules.

Re: I recreated the io and os modules using Ndless

Message non luPosté: 03 Juil 2020, 20:58
de Adriweb
Nice job :)
Levak did that as well for earlier versions, many years ago :p

Re: I recreated the io and os modules using Ndless

Message non luPosté: 03 Juil 2020, 22:32
de Ti64CLi++
Nice job indeed :bj:
It's true that some of them are very useful and were missing.
File related functions are particularly welcomed ^^