Omnimaga

Calculator Community => TI Calculators => Lua => Topic started by: blauemauritius on August 04, 2013, 03:06:08 pm

Title: Nspire - Lua - xpcall
Post by: blauemauritius 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
Title: Re: Nspire - Lua - xpcall
Post by: Levak 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 ?
Title: Re: Nspire - Lua - xpcall
Post by: blauemauritius 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.
Title: Re: Nspire - Lua - xpcall
Post by: blauemauritius 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?
Title: Re: Nspire - Lua - xpcall
Post by: Levak 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
Title: Re: Nspire - Lua - xpcall
Post by: blauemauritius 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.
Title: Re: Nspire - Lua - xpcall
Post by: Adriweb 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]
Title: Re: Nspire - Lua - xpcall
Post by: blauemauritius on August 04, 2013, 05:04:35 pm
Thank you. I will try it tomorrow.

Good night.