?
Solved

Convert String to Char?

Posted on 2001-08-28
3
Medium Priority
?
361 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 120 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

752 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