π
<-

Lua check if device has CAS

Pour TI-Nspire OS 3.0 ou ultérieur.

Lua check if device has CAS

Unread postby 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?
User avatar
fredrik.ekelof
Niveau 4: MC (Membre Confirmé)
Niveau 4: MC (Membre Confirmé)
Level up: 88%
 
Posts: 10
Joined: 09 Oct 2019, 13:37
Gender: Not specified
Calculator(s):
MyCalcs profile

Re: Lua check if device has CAS

Unread postby 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: Select all
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
User avatar
critorAdmin
Niveau 19: CU (Créateur Universel)
Niveau 19: CU (Créateur Universel)
Level up: 54.4%
 
Posts: 42483
Images: 17331
Joined: 25 Oct 2008, 00:00
Location: Montpellier
Gender: Male
Calculator(s):
MyCalcs profile
YouTube: critor3000
Twitter: critor2000
GitHub: critor

Re: Lua check if device has CAS

Unread postby 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)

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...)
My calculator programs
Mes programmes pour calculatrices
User avatar
AdriwebAdmin
Niveau 16: CC2 (Commandeur des Calculatrices)
Niveau 16: CC2 (Commandeur des Calculatrices)
Level up: 82.1%
 
Posts: 14880
Images: 1211
Joined: 01 Jun 2007, 00:00
Location: France
Gender: Male
Calculator(s):
MyCalcs profile
Twitter: adriweb
GitHub: adriweb

Re: Lua check if device has CAS

Unread postby 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.
User avatar
fredrik.ekelof
Niveau 4: MC (Membre Confirmé)
Niveau 4: MC (Membre Confirmé)
Level up: 88%
 
Posts: 10
Joined: 09 Oct 2019, 13:37
Gender: Not specified
Calculator(s):
MyCalcs profile


Return to Nspire-Lua

Who is online

Users browsing this forum: ClaudeBot [spider] and 1 guest

-
Search
-
Social TI-Planet
-
Featured topics
Ndless for CX 4.5.5 / CX II 6.2.0
Comparaisons des meilleurs prix pour acheter sa calculatrice !
"1 calculatrice pour tous", le programme solidaire de Texas Instruments. Reçois gratuitement et sans aucune obligation d'achat, 5 calculatrices couleur programmables en Python à donner aux élèves les plus nécessiteux de ton lycée. Tu peux recevoir au choix 5 TI-82 Advanced Edition Python ou bien 5 TI-83 Premium CE Edition Python.
Enseignant(e), reçois gratuitement 1 exemplaire de test de la TI-82 Advanced Edition Python. À demander d'ici le 31 décembre 2024.
Aidez la communauté à documenter les révisions matérielles en listant vos calculatrices graphiques !
12345
-
Donations / Premium
For more contests, prizes, reviews, helping us pay the server and domains...
Donate
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.
3486 utilisateurs:
>3450 invités
>30 membres
>6 robots
Record simultané (sur 6 mois):
32248 utilisateurs (le 01/09/2025)
-
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)