π
<-
Chat plein-écran
[^]

I recreated the io and os modules using Ndless

Pour TI-Nspire OS 3.0 ou ultérieur.

I recreated the io and os modules using Ndless

Unread postby nspiredev500 » 03 Jul 2020, 20:39

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.
Attachments
io.luax.tns
(87.32 KiB) Downloaded 5 times
os.luax.tns
(109.24 KiB) Downloaded 5 times
User avatar
nspiredev500
Niveau 4: MC (Membre Confirmé)
Niveau 4: MC (Membre Confirmé)
Level up: 62.5%
 
Posts: 9
Joined: 03 Jul 2020, 12:22
Gender: Not specified
Calculator(s):
GitHub: nspiredev500

Re: I recreated the io and os modules using Ndless

Unread postby Adriweb » 03 Jul 2020, 20:58

Nice job :)
Levak did that as well for earlier versions, many years ago :p
User avatar
AdriwebAdmin
Niveau 16: CC2 (Commandeur des Calculatrices)
Niveau 16: CC2 (Commandeur des Calculatrices)
Level up: 54.5%
 
Posts: 12971
Images: 1087
Joined: 01 Jun 2007, 00:00
Location: France
Gender: Male
Calculator(s):
Class: (ingénieur)
Twitter: adriweb
GitHub: adriweb

Re: I recreated the io and os modules using Ndless

Unread postby Ti64CLi++ » 03 Jul 2020, 22:32

Nice job indeed :bj:
It's true that some of them are very useful and were missing.
File related functions are particularly welcomed ^^
Image
User avatar
Ti64CLi++Modo
Niveau 15: CC (Chevalier des Calculatrices)
Niveau 15: CC (Chevalier des Calculatrices)
Level up: 90.2%
 
Posts: 3260
Images: 75
Joined: 04 Jul 2014, 14:40
Location: Clermont-Ferrand 63
Gender: Male
Calculator(s):
Class: Maths Sup
GitHub: Ti64CLi


Return to Nspire-Lua

Who is online

Users browsing this forum: No registered users and 0 guests

-
Search
-
Featured topics
L'OS 5.5 de la TI-83 Premium CE / 84 Plus CE supprime l'assembleur - la plupart des jeux et certains programme ne fonctionneront plus
Omega, le fork étendant les capacités de ta NumWorks, même en mode examen !
Découvre les nouvelles fonctionnalités en Python de l'OS 5.5 pour la 83PCE/84+C-T Python Edition
Comparaisons des meilleurs prix pour acheter sa calculatrice !
1234
-
Donations / Premium
For more contests, prizes, reviews, helping us pay the server and domains...

Discover the the advantages of a donor account !
JoinRejoignez the donors and/or premium!les donateurs et/ou premium !


Partner and ad
Notre partenaire Jarrety Calculatrices à acheter chez Calcuso
-
Stats.
681 utilisateurs:
>669 invités
>9 membres
>3 robots
Record simultané (sur 6 mois):
6892 utilisateurs (le 07/06/2017)
-
Other interesting websites
Texas Instruments Education
Global | France
 (English / Français)
Banque de programmes TI
ticalc.org
 (English)
La communauté TI-82
tout82.free.fr
 (Français)