Hi
Is it possible in Lua to verify/check that a program is running on a CAS unit, either hand held or software? I would like to avoid unexpected behavior of a program using CAS functions, running on non cas software.
The TI Lua API reference guide is a little cryptic on this matter. platform.hw() seems to return only 3 (hand held) or 7 (computer) independent of CAS. Command platform.getDeviceID() does not seem to return anything, anyway on the computer, so that will not work.
What happens if you try to run CAS commands on a non CAS unit in Lua, like math.eval("solve(x+2=4,x)")?
By testing to turn off CAS on my TI CX II-T CAS, and running solve(x+2=4,x) in the scratchpad returns a error popup stating like "limited capabilities when CAS is off". What would happen on a non CAS unit? By trying to run the same command from LUA it returns "nil 1327", however error code 1327 is not documented in the the TI CAS reference guide(latest version from TI web page). What error code would a non cas unit return?
Lua check if device has CAS
Voir le premier message non lu • 4 messages
• Page 1 sur 1
-
fredrik.ekelof
Niveau 4: MC (Membre Confirmé)- Messages: 10
- Inscription: 09 Oct 2019, 13:37
- Genre:
- Calculatrice(s):→ MyCalcs profile
Re: Lua check if device has CAS
Hi.
Instead of using CAS functions (which are just going to trigger an error on non-CAS calculators), you may just calculate something.
For example, here's a TI-Basic function :
You may then just call it from your Lua script :
Instead of using CAS functions (which are just going to trigger an error on non-CAS calculators), you may just calculate something.
For example, here's a TI-Basic function :
- Code: Tout sélectionner
Define iscas()=
Func
Local p
π→p
Return getType(p)="EXPR"
EndFunc
You may then just call it from your Lua script :
iscas = math.evalStr("iscas()")
.-
critorAdmin
Niveau 19: CU (Créateur Universel)- Messages: 41500
- Images: 14703
- Inscription: 25 Oct 2008, 00:00
- Localisation: Montpellier
- Genre:
- Calculatrice(s):→ MyCalcs profile
- YouTube: critor3000
- Twitter/X: critor2000
- GitHub: critor
Re: Lua check if device has CAS
The (almost) shortest answer for Nspire-Lua would be
You can set this global in an early-defined configuration or something, from on.resize for instance. Then you can just use "isCAS" wherever you need it.
(This was the topic of our first lua mini-challenge many years ago hah)
isCAS = not not math.evalStr('?')
actually You can set this global in an early-defined configuration or something, from on.resize for instance. Then you can just use "isCAS" wherever you need it.
(This was the topic of our first lua mini-challenge many years ago hah)
MyCalcs: Help the community's calculator documentations by filling out your calculators info!
MyCalcs: Aidez la communauté à documenter les calculatrices en donnant des infos sur vos calculatrices !
Inspired-Lua.org: All about TI-Nspire Lua programming (tutorials, wiki/docs...)-
AdriwebAdmin
Niveau 16: CC2 (Commandeur des Calculatrices)- Messages: 14616
- Images: 1218
- Inscription: 01 Juin 2007, 00:00
- Localisation: France
- Genre:
- Calculatrice(s):→ MyCalcs profile
- Twitter/X: adriweb
- GitHub: adriweb
Re: Lua check if device has CAS
Thanks for your answers.
I will go for isCAS = not not math.evalStr('?') . This one was a really neat trick.
I will go for isCAS = not not math.evalStr('?') . This one was a really neat trick.
-
fredrik.ekelof
Niveau 4: MC (Membre Confirmé)- Messages: 10
- Inscription: 09 Oct 2019, 13:37
- Genre:
- Calculatrice(s):→ MyCalcs profile
4 messages
• Page 1 sur 1
Qui est en ligne
Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 30 invités