convert "42" to 42

BlitzMax Forums/BlitzMax Beginners Area/convert "42" to 42

Dubious Drewski(Posted 2005) [#1]
Does anyone here know how I might do that?

I'm trying to find the difference between a string 1 and an integer 1, but to no avail:
Strict
Local a:String= "1"
Local b=1
Print a
Print b
Print Bin(a)
Print Bin(b)



deps(Posted 2005) [#2]
print a[0] ' ascii value



TomToad(Posted 2005) [#3]
Not sure what you're asking, if you just want to convert a string to an Int, just cast the number like this
Print Bin(Int(a))

If you want to know the ASCII value of the character "1" then use the Asc() command.
Print Bin(Asc(a))



Dubious Drewski(Posted 2005) [#4]
Ah that's right, strings are arrays.
Thanks deps.
I wouldn't have assumed printing it like you did
would give me the ascii value. Huh.

[edit] And TomToad, the Int(a) would actually be the best way to do it for my purposes. Thank you also.