On Feb 26, 3:26 pm, Dennis-Bendert Schramm <dennisschr...@[EMAIL PROTECTED]
>
wrote:
> Hello,
>
> how do I convert a ShortString into PChar? I just tried
> pchar([ShortStringPutHere]) but that gave me an error message.
>
> I'm developing an ncurses based app and I need to convert ShortString
> strings to Pchar to use them with the mvwaddstr and mvprintw functions.
>
> Thanks in advance,
>
> Dennis B. Schramm
Hi Dennis,
>From a recent post "freepascal strings,"
To create C strings (null terminated pointers to a sequence of
characters) one might do the following;
Function Create_Cstring(PascalString : String) : Cstring;
Var NewString : String;
Convert_To_Cstring : Cstring;
Begin
NewString := PascalString + Chr(0) ;
Convert_To_Cstring := @[EMAIL PROTECTED]
;
Create_Cstring := StrNew(Convert_To_Cstring) ;
End;
The reason I do it this way is not to modify the original shortstring.
The CString is a pchar and is what ncurses wants.
I'm not the expert on this, but this works for my ncurses apps. You
need the strings unit for the StrNew function. Wolf advised to use
StrPCopy.
I don't know how you are using the mvprintw function. The mvwaddstr
function works.
If the compiler identifies your shortstrings as ansistrings then you
are in a delphi mode.


|