Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

convert string to pchar

0 views
Skip to first unread message

Vincent Vijt

unread,
Oct 18, 1999, 3:00:00 AM10/18/99
to
hi,

how do i convert a string to a pchar?

i allready know how to convert a pchartostr:

Function PCharToStr( p: pChar; Len: WORD ): String;
Var
s: String;
Begin
SetLength( s, Len );
Move( p^, s[1], Len );
If POS( #0, s ) > 0 Then
SetLength( s, POS( #0, s ) - 1 );
RESULT := s;
End

please help,

Vincent

pa...@nospam.com

unread,
Oct 18, 1999, 3:00:00 AM10/18/99
to
Simple ! Typecast it

var
s:string;

Begin
s:='abc';

....pchar(s).....

Steve Koterski

unread,
Oct 18, 1999, 3:00:00 AM10/18/99
to
On Mon, 18 Oct 1999 21:19:36 +0200, "Vincent Vijt"
<vi...@planetinternet.be> wrote:

>how do i convert a string to a pchar?

See the online help for the StrPCopy function.

>i allready know how to convert a pchartostr:
>
>Function PCharToStr( p: pChar; Len: WORD ): String;
>Var
> s: String;
>Begin
> SetLength( s, Len );
> Move( p^, s[1], Len );
> If POS( #0, s ) > 0 Then
> SetLength( s, POS( #0, s ) - 1 );
> RESULT := s;
>End

The built-in Delphi function for copying from PChar to String is StrPas.

_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
Steve Koterski "Health nuts are going to feel stupid someday,
Felton, CA lying in hospitals dying of nothing."
-- Redd Foxx

Danjel Grosar

unread,
Oct 19, 1999, 3:00:00 AM10/19/99
to
try to use this method where you need pchar!


put in >>> zs : array[0..119] of Char; <<<
in variable sector of your procedure or function

and use this >>> StrPCopy( zs , s ); <<< in line where you need Pchar!

!!!! i try to make a simple function like below but the function not
export value !!!!

function StringToPchar( S : string ): Pchar;

var zs : array[0..119] of Char;

begin
result := StrPCopy( zs , s );
end;


Danjel

0 new messages