FBA The Creator
http://www.fbacreator.com/fbaforum/

Converting strings to integers?
http://www.fbacreator.com/fbaforum/viewtopic.php?f=5&t=61
Page 1 of 1

Author:  Boiled Sweets [ Wed Jun 25, 2008 12:17 pm ]
Post subject:  Converting strings to integers?

I want to read in a 3 digit number from a text file so using getres(0,3)
But how do I turn this into a numeric/integar?

Author:  phrebh [ Wed Jun 25, 2008 12:59 pm ]
Post subject:  Re: Converting strings to integers?

I've found that the interpreter converts them automatically without problem. I don't have any code to force it in my calculator. But if it isn't working or you want to be sure, try using tonumber("string"), which is a Lua function that seems to work just fine in FBA based on my small test.

Author:  umbiomar [ Wed Jun 25, 2008 1:01 pm ]
Post subject:  Re: Converting strings to integers?

Not sure to understand your question but the following works:

Code:
openres("resource.txt")
num = getres(0, 3)
num=num+1
closeres()

function onmainloop()
        print(100,100,num,255,255,255)
end

Author:  Boiled Sweets [ Wed Jun 25, 2008 1:07 pm ]
Post subject:  Re: Converting strings to integers?

tonumber did it! Thanks...

I guess I ought to take a look at the LUA docs :-)

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Limited
https://www.phpbb.com/