π
<-
Chat plein-écran
[^]

Lua check if device has CAS

Pour TI-Nspire OS 3.0 ou ultérieur.

Lua check if device has CAS

Message non lude fredrik.ekelof » 27 Oct 2019, 21:20

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?
Avatar de l’utilisateur
fredrik.ekelof
Niveau 4: MC (Membre Confirmé)
Niveau 4: MC (Membre Confirmé)
Prochain niv.: 88%
 
Messages: 10
Inscription: 09 Oct 2019, 13:37
Genre: Non spécifié
Calculatrice(s):
MyCalcs profile

Re: Lua check if device has CAS

Message non lude critor » 27 Oct 2019, 21:49

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 :
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()").
Image
Avatar de l’utilisateur
critorAdmin
Niveau 19: CU (Créateur Universel)
Niveau 19: CU (Créateur Universel)
Prochain niv.: 42.3%
 
Messages: 41496
Images: 14632
Inscription: 25 Oct 2008, 00:00
Localisation: Montpellier
Genre: Homme
Calculatrice(s):
MyCalcs profile
YouTube: critor3000
Twitter/X: critor2000
GitHub: critor

Re: Lua check if device has CAS

Message non lude Adriweb » 27 Oct 2019, 23:02

The (almost) shortest answer for Nspire-Lua would be 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)
Image

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...)
Avatar de l’utilisateur
AdriwebAdmin
Niveau 16: CC2 (Commandeur des Calculatrices)
Niveau 16: CC2 (Commandeur des Calculatrices)
Prochain niv.: 80.2%
 
Messages: 14615
Images: 1218
Inscription: 01 Juin 2007, 00:00
Localisation: France
Genre: Homme
Calculatrice(s):
MyCalcs profile
Twitter/X: adriweb
GitHub: adriweb

Re: Lua check if device has CAS

Message non lude fredrik.ekelof » 28 Oct 2019, 19:42

Thanks for your answers.

I will go for isCAS = not not math.evalStr('?') . This one was a really neat trick.
Avatar de l’utilisateur
fredrik.ekelof
Niveau 4: MC (Membre Confirmé)
Niveau 4: MC (Membre Confirmé)
Prochain niv.: 88%
 
Messages: 10
Inscription: 09 Oct 2019, 13:37
Genre: Non spécifié
Calculatrice(s):
MyCalcs profile


Retourner vers Nspire-Lua

Qui est en ligne

Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 14 invités

-
Rechercher
-
Social TI-Planet
-
Sujets à la une
Comparaisons des meilleurs prix pour acheter sa calculatrice !
Aidez la communauté à documenter les révisions matérielles en listant vos calculatrices graphiques !
Phi NumWorks jailbreak
123
-
Faire un don / Premium
Pour plus de concours, de lots, de tests, nous aider à payer le serveur et les domaines...
Faire un don
Découvrez les avantages d'un compte donateur !
JoinRejoignez the donors and/or premium!les donateurs et/ou premium !


Partenaires et pub
Notre partenaire Jarrety Calculatrices à acheter chez Calcuso
-
Stats.
1437 utilisateurs:
>1412 invités
>20 membres
>5 robots
Record simultané (sur 6 mois):
6892 utilisateurs (le 07/06/2017)
-
Autres sites intéressants
Texas Instruments Education
Global | France
 (English / Français)
Banque de programmes TI
ticalc.org
 (English)
La communauté TI-82
tout82.free.fr
 (Français)