int to string, string to int?
BlitzMax Forums/BlitzMax Beginners Area/int to string, string to int?
| ||
Greetings, I can't seem to figure out how to convert between strings and integer variables and vice versa. Can someone please point me in the right direction? Thanks, -Garrett |
| ||
Local s:String = "1" Local g:Int g= s.toInt() Print g g:+ 2 s = g Print s |
| ||
So toInt() and toString()? Arf! I was looking for Int() and Str(). :-) Thanks a bunch, -Garrett |
| ||
take a look in the help under language->strings for all the methods. |
| ||
newInt% = oldStr$.ToInt() newInt% = Int(oldStr$) newStr$ = oldInt% newStr$ = String.FromInt(oldInt%) newStr$ = String(oldInt%) |
| ||
Anybody know what module is related to the toInt() ? Thanks, -Garrett |
| ||
Nevermind, don't need to know the module. Thanks, -Garrett |
| ||
brl.blitz contains the string declaration (in C). |
| ||
Yan: thats good but you forgot to mention wich one you prefer. I am shure one of those is the fastest for in game operations. DO you know? or will my I have to figure it out? :) |
| ||
Jesse without running any of them my money is on newStr$ = String.FromInt(oldInt%) and newInt% = oldStr$.ToInt() as being the fastest |
| ||
I tend to use...newInt% = Int(oldStr$) newStr$ = oldInt%...But only cos I'm comfortable doing it that way. I'm pretty sure that any difference in speed, if indeed there is any (I've got a feeling they're exactly the same when compiled), is far too slight to be worth worrying about. |