Solved

Convert String to Char?

Posted on 2001-08-28
3
357 Views
Last Modified: 2010-04-06
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?

0
Comment
Question by:bjornborg
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 6

Accepted Solution

by:
edey earned 30 total points
ID: 6433187
to get the ord value of the _third_ char in a string, try this:

ord(myString[2]);


GL
Mike
0
 
LVL 2

Expert Comment

by:bugroger
ID: 6433746
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
 
LVL 6

Expert Comment

by:edey
ID: 6434106
Umm, yeah, that's right! Sorry about the little mixup :).

GL
Mike
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question