Solved

string to Char coonversion

Posted on 1997-12-14
8
6,891 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
[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
  • 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
Technology Partners: 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!

 
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

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

695 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