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

best way to collect a string of characters
http://www.fbacreator.com/fbaforum/viewtopic.php?f=5&t=33
Page 1 of 1

Author:  FR4NK5T3R [ Thu Apr 10, 2008 10:38 pm ]
Post subject:  best way to collect a string of characters

Ok after someone else mentioned doing a calculator i thought i'd have a go but it's proving difficult.
I have my user interface and I'm collecting numbers as pressed and I'm trying to do this with numerical variables e.g.

num = num * 10 + keypressed

to build up my integer then

num = num + keypressed/10 * count

to build up the fraction after the decimal place

Anyway I'm sure it would be a lot easier to collect and append characters in a string and then evaluate it all to a number at the end.

Is there an expression where I can add say "1" + "2" + "3" and it becomes "123" rather than being immediately treated as numbers and becoming 6 ?

Author:  evilmaio [ Thu Apr 10, 2008 10:47 pm ]
Post subject:  Re: best way to collect a string of characters

You have to use the LUA string concat operator:

Code:
..

instead of sum operator.

For example:
Code:
debug(1+2)
-- this will output: 3

Code:
debug ("1".."2")
-- this will output: "12"

Code:
a="hi"
b="to all"
debug(a .. " " .. b)
-- this will output: "hi to all"

Author:  FR4NK5T3R [ Fri Apr 11, 2008 7:44 am ]
Post subject:  Re: best way to collect a string of characters

excellent thanks I'll try that later

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