How to deal with some character of a string !!
kevinspace
Posts: 56
Hi everybody!
How to deal with some character of a string !!
Ex :
I get a string as "SetValue100", and how to pick up the characters "100" only ?
And how to convert the "100" to a decimal value?
Are there any suggesstion or any examples ?
Thanks a lot !!
How to deal with some character of a string !!
Ex :
I get a string as "SetValue100", and how to pick up the characters "100" only ?
And how to convert the "100" to a decimal value?
Are there any suggesstion or any examples ?
Thanks a lot !!
Comments
if the position of the number is always the same
you can catch the "100"
by MyString[ 8 ], MyString[ 9 ], MyString[ 10 ]
otherways you would have o parse for characters that are digits.
Or maybe adding a special character that indicates next bytes are the number
to make a decimal number out of the Charactersequence "100" you can use the
from the FullDuplexSerialPlus-object
best regards
Stefan
In Spin it is a few more lines, like Stefan says.
KyeDOS has some string driver code, and it has MID like in MBASIC. VAL is "DecimalToInteger". Kye wrote most of this code and I added a few things.
In the main program, define some general purpose string variables
And set up the string object
These are some code examples testing the string functions
and this is the string object