Author Topic: Executing a program using mathEval() function?  (Read 1438 times)

0 Members and 1 Guest are viewing this topic.

Offline Goran

  • LV2 Member (Next: 40)
  • **
  • Posts: 32
  • Rating: +0/-0
    • View Profile
Executing a program using mathEval() function?
« on: August 23, 2013, 04:47:54 am »

I tried to execute a program from a Lua script, but this seems not to be allowed
(I get Error 580):

    local ans,err = math.eval('prog1(<args>)')

Originally I wanted to create a function to get result, but then some of the ti math engine functions
were not allowed to be used from within a function (e.g. CopyVar, DelVar).

Then I said I would encapsulate the functionality into a program, which will during its execution create
variables in the symbol table and then I will fetch these variables from my Lua script.

When I run the program directly from e.g. Calculator app, it works as wanted and I have all the variables I want in the symbol table.
But if I try to execute the program using mathEval() function, I end with Error 580.

I feel it's little bit of a "catch 22" situation.

Best regards,

Offline Levak

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +208/-39
    • View Profile
    • My website
Re: Executing a program using mathEval() function?
« Reply #1 on: August 23, 2013, 04:51:32 am »
Only functions (not programs) can be executed through math.eval().
Indeed, programs affect the global environnement and do not return a value.

In order to modify the global environnement, please use
I do not get mad at people, I just want them to learn the way I learnt.
My website - TI-Planet - iNspired-Lua