Solved

string to Char coonversion

Posted on 1997-12-14
8
6,879 Views
Last Modified: 2012-05-04
is there any way to convert "D" as a string type into "D" as a char type with Delphi 3?
0
Comment
Question by:arint
  • 3
  • 2
  • 2
  • +1
8 Comments
 

Author Comment

by:arint
ID: 1353576
Edited text of question
0
 
LVL 4

Expert Comment

by:itamar
ID: 1353577
What about ?

var
  St : String;
  Ch : PChar;
begin
  Ch := PChar(St);
  ...
end;

0
 
LVL 5

Expert Comment

by:JimBob091197
ID: 1353578
itamar's answer will convert string to PChar.  If you want to convert string to Char, try this:

var
  c: PChar;
  s: string;
begin
  c := ' ';
  if (Length(s) > 0) then
    c := @s[1];
  ...
end;

JB
0
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
LVL 5

Expert Comment

by:JimBob091197
ID: 1353579
P.S.  Should read
    c := s[1];
NOT
    c := @s[1];

JB
0
 
LVL 1

Accepted Solution

by:
aluiken earned 50 total points
ID: 1353580
yeah sure

Procedure WhatEver(S : String);
Var Ch : Char;
Begin
 Ch := S[1];
End;

now ch will contain the first char of string <S>

thats it,

regards Arijan
0
 
LVL 4

Expert Comment

by:itamar
ID: 1353581
HEI !

Isn't this "proposed answer" the JimBob's comment put as an answer ?? :<
0
 
LVL 1

Expert Comment

by:aluiken
ID: 1353582
yeah but if you leave the question open it's easy point's !!
0
 
LVL 5

Expert Comment

by:JimBob091197
ID: 1353583
You clearly have a good idea of the spirit in which Experts Exchange is run...
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

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…
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…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

777 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