Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Pascal Misc > Re: ShortString...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 7 of 7 Topic 723 of 806
Post > Topic >>

Re: ShortString to PChar

by "Richard Engebretson" <eng@[EMAIL PROTECTED] > Feb 27, 2007 at 05:01 AM

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.
 




 7 Posts in Topic:
ShortString to PChar
Dennis-Bendert Schramm &l  2007-02-26 22:26:13 
Re: ShortString to PChar
Marco van de Voort <ma  2007-02-26 21:29:16 
Re: ShortString to PChar
Dennis-Bendert Schramm &l  2007-02-26 23:45:19 
Re: ShortString to PChar
Wolf Behrenhoff <NoSpa  2007-02-26 23:56:02 
Re: ShortString to PChar
Marco van de Voort <ma  2007-02-27 08:46:02 
Re: ShortString to PChar
Dennis-Bendert Schramm &l  2007-02-27 23:29:07 
Re: ShortString to PChar
"Richard Engebretson  2007-02-27 05:01:07 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sun Jul 6 6:34:12 CDT 2008.