Jump to content



Photo

Question About String To Equation


  • Please log in to reply
1 reply to this topic

#1 flyingfisch

flyingfisch

    Casio Maniac

  • Deputy
  • PipPipPipPipPipPipPipPip
  • 1891 posts
  • Gender:Male
  • Location:OH,USA
  • Interests:Aviation, Skiing, Programming, Mountain Biking.

  • Calculators:
    fx-9860GII
    fx-CG10 PRIZM

Posted 15 November 2011 - 06:25 PM

Will this code:

local strEval = base.tonumber
eval = "if a==1 then a=2 end"

strEval(eval)

Do the same as this code?

if a==1 then a=2 end

Or will i get an error. (I am trying to make a parser/shell for luaFX)

#2 veb

veb

    Casio Fan

  • Members
  • PipPip
  • 43 posts

Posted 18 November 2011 - 05:39 PM

No this code won't do the same.

In fact, base.tonumber("mystring") returns the number that might be contained in mystring.


base.tonumber(" 2e3") return 2000

but base.tonumber (" a = 1") will raise an error because 'a =' is not a number


In the original lua, there is some functions to execute code in a string, but I couldn't include these functions for luafx because they need to compile the parser: that is impossible on AFX (due to exe size restriction)

You can find on internet some lua parser written in lua, but they are too big for luafx...

Edited by veb, 18 November 2011 - 05:40 PM.



0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users