Convert String to Char?

This is probably very easy, but still:

I would like to return the ord() value of a character:

ord('c') returns 99

but if I try to extract the letter from a string like this:
 Mystring := midstr(strLongString,nbrStartPos,1); //e.g 'c'

and then want to use the function

 nbrThatItIs := ord(Mystring);

I get an error because Mystring is "string" and I need to use Char.

So: How do I best convert my string to char?

bjornborgAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
edeyConnect With a Mentor Commented:
to get the ord value of the _third_ char in a string, try this:

ord(myString[2]);


GL
Mike
0
 
bugrogerCommented:
Edey, i think you mean "the value of the _second_ char
in a string" and the _third_ in a PChar. :-)

s = '123';
 
ord(s[2]);         -> "2"
ord(PChar(s)[2]);  -> "3"
0
 
edeyCommented:
Umm, yeah, that's right! Sorry about the little mixup :).

GL
Mike
0
All Courses

From novice to tech pro — start learning today.