Author Topic: Nspire - Lua - xpcall  (Read 5699 times)

0 Members and 1 Guest are viewing this topic.

Offline blauemauritius

  • LV2 Member (Next: 40)
  • **
  • Posts: 25
  • Rating: +0/-0
    • View Profile
Nspire - Lua - xpcall
« on: August 04, 2013, 03:06:08 pm »
Hello,

i want to use in a LUA script xpcall(). Does anyone know how? Can i use any function which i have created with the program editor?

Thank you in advance.

blauemauritius

Offline Levak

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +208/-39
    • View Profile
    • My website
Re: Nspire - Lua - xpcall
« Reply #1 on: August 04, 2013, 03:15:26 pm »
Hi,

Why would you use xpcall instead of pcall since on TI-Nspire the "debug" package is not available ?
Anyway, just google-it
http://www.fxcodebase.com/documents/IndicoreSDK/lua/pdf-xpcall.html
http://www.lua.org/pil/8.5.html

Quote
Can i use any function which i have created with the program editor?
I don't understand your question (maybe because its answer is obvious) I'm just looking forward finding a deeper problem : do you have any source code ?
« Last Edit: August 04, 2013, 03:17:50 pm by Levak »
I do not get mad at people, I just want them to learn the way I learnt.
My website - TI-Planet - iNspired-Lua

Offline blauemauritius

  • LV2 Member (Next: 40)
  • **
  • Posts: 25
  • Rating: +0/-0
    • View Profile
Re: Nspire - Lua - xpcall
« Reply #2 on: August 04, 2013, 03:18:41 pm »
thank you. I will see what is written in your links.

I will give you a feedback.

Offline blauemauritius

  • LV2 Member (Next: 40)
  • **
  • Posts: 25
  • Rating: +0/-0
    • View Profile
Re: Nspire - Lua - xpcall
« Reply #3 on: August 04, 2013, 03:23:33 pm »
thank you... Is the call and the structure in LUA for NSpire the same?

Do you have a short example?

Offline Levak

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +208/-39
    • View Profile
    • My website
Re: Nspire - Lua - xpcall
« Reply #4 on: August 04, 2013, 04:23:49 pm »
thank you... Is the call and the structure in LUA for NSpire the same?
Yes, the same. TI did not reinvented the Lua, they only turned it event-based and added their API.
Quote
Do you have a short example?
The example given in the second link will work
Code: [Select]
local status, err = pcall(function () a = 'a'+1 end)
print(err)     --> stdin:1: attempt to perform arithmetic on a string value

local status, err = pcall(function () error("my error") end)
print(err)     --> stdin:1: my error
« Last Edit: August 04, 2013, 04:24:11 pm by Levak »
I do not get mad at people, I just want them to learn the way I learnt.
My website - TI-Planet - iNspired-Lua

Offline blauemauritius

  • LV2 Member (Next: 40)
  • **
  • Posts: 25
  • Rating: +0/-0
    • View Profile
Re: Nspire - Lua - xpcall
« Reply #5 on: August 04, 2013, 04:36:24 pm »
Thank you. It Looks that i have to write a function between the brackets.

My question was: can i use with pcall or xpcall functions Or procedures which i wrote in TI-basic in the TI program editor?

Thank you for your great support. I hope my english is not too bad.

Offline Adriweb

  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1708
  • Rating: +229/-17
    • View Profile
    • TI-Planet.org
Re: Nspire - Lua - xpcall
« Reply #6 on: August 04, 2013, 04:59:01 pm »
You can call functions (not programs) that you wrote within the Basic Editor, yes.

That's through [lua]math.eval[/lua]
My calculator programs
TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation

Offline blauemauritius

  • LV2 Member (Next: 40)
  • **
  • Posts: 25
  • Rating: +0/-0
    • View Profile
Re: Nspire - Lua - xpcall
« Reply #7 on: August 04, 2013, 05:04:35 pm »
Thank you. I will try it tomorrow.

Good night.