Simple ASCII access

Monkey Archive Forums/Monkey Tutorials/Simple ASCII access

Shagwana(Posted 2013) [#1]
ASCII is a way text (can be) held in computer. So this is a simple little guide on how to obtain these numbers from a string and how to convert these numbers back into a strings via Monkey code.

To convert a given letter in a string into a ASCII value you can...
Local sName:String="Goosey Flipflop!"
Print sName[0] 'prints 71 for letter G
Print sName[3] 'prints 115 for letter s

To convert a ASCII value back into a string you can..
Local iNum:Int=80
Print String.FromChar(iNum)  'prints "P"

Also of note you can do...
print "something"[3]     'print the ASCII value of 'e'

I am sure this will help someone!

Shagwana(Posted 2013) [#2]
I wupsied and did a double post!

skid(Posted 2013) [#3]
ASCII is actually a 7 bit format that is a subset of Unicode.

As Monkey uses Unicode it is a little more technically correct if you changed "ASCII value" to "Unicode Code point".