monkey.boxes

Monkey Forums/Monkey Programming/monkey.boxes

Richard Betson(Posted 2015) [#1]
Hi,

I am trying to covert a value type (string) to an integer using monkey.boxes ToInt(). So far I'm lost on how to do this. I understand the concept I just don't know how to implement it.

So for example this is how I thought it might work but does not.
Local mystring:StringObject
Print mystring.ToInt()


Lost I am. :)


Nobuyuki(Posted 2015) [#2]
Any reason you need to box these values to cast them? Try casting a string directly:

Local myString:String = "16"
DrawCircle( x,y, Int(myString))  'Last value explicitly casts myString to Int.  If it fails, the cast returns 0.  This will fail on decimal values!



Richard Betson(Posted 2015) [#3]
^There is none. :) I did not know that Monkey did that. Thanks I think that will do fine.


marksibly(Posted 2015) [#4]
I'd recommend avoiding monkey.boxes - it's a bit of a relic from an earlier version of monkey.


Richard Betson(Posted 2015) [#5]
^10-4 good-buddy ;)