ASCII Byte Value from Single String Variable

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
bernoulli
Posts: 22
Joined: Sat Dec 12, 2015 10:18 am
Has thanked: 1 time

ASCII Byte Value from Single String Variable

Post by bernoulli »

Is there a command which places the ASCII value of a one length string variable to a byte variable?

For clarity:
StringVariable[1] = "A"
ByteVariable = SomeCommand(StringVariable)

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: ASCII Byte Value from Single String Variable

Post by Benj »

Hello

You can just use the string as an array of bytes.

So for example you can do this.

StrVar = "Hello World"
ByteVar = StrVar[6]

ByteVar then should equal 'W'

This topic might help with some advanced string manipulation techniques.
viewtopic.php?f=63&t=17975&p=76223#p76223

bernoulli
Posts: 22
Joined: Sat Dec 12, 2015 10:18 am
Has thanked: 1 time

Re: ASCII Byte Value from Single String Variable

Post by bernoulli »

Thank you, Benj !

Post Reply