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
var
s:string;
Begin
s:='abc';
....pchar(s).....
>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
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