Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2009-09

String to PString assignment?

4 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Graeme Geldenhuys

Hi,

I'm converting a project from Sibyl (a old OS/2 IDE implement in SpeedSoft Pascal).

Below is the code I'm trying to convert to Free Pascal. I see FPC has a PString type, but not FreePString() or NewPString(). Searching the FPC source code, I found the FP Text IDE using PString all over. The FP Text IDE uses this... <some PString var> := NewStr(<string>);

Do I need this when I use String = AnsiString in my projects?  Or can I
simply do the following assignment:  _Title := @NevValue;
---------------------------------
_Title: PString;

...

procedure TTopic.SetTitle( const NewValue: string );
begin
  FreePString( _Title );
  _Title:= NewPString( NewValue );
end;
---------------------------------

Sorry if this sounds dumb, but I have never used PString before.

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net/fpgui/

Reply by email

Marco van de Voort
to Graeme Geldenhuys: I'm converting a project from Sibyl (a old OS/2 IDE implement in SpeedSoft Pascal). Below…

In our previous episode, Graeme Geldenhuys said:

Show quoted text 11 lines
I'm converting a project from Sibyl (a old OS/2 IDE implement in SpeedSoft Pascal). Below is the code I'm trying to convert to Free Pascal. I see FPC has a PString type, but not FreePString() or NewPString(). Searching the FPC source code, I found the FP Text IDE using PString all over. The FP Text IDE uses this... <some PString var> := NewStr(<string>); Do I need this when I use String = AnsiString in my projects? Or can I simply do the following assignment: _Title := @NevValue;

If you want to ansistringify, assume that pstring as a whole is ansistring, and remove all pointers and let ansistrings automatic maintenance work.

Be careful with newstr, there are multiple versions of it. (a TP and Delphi version) see
http://wiki.freepascal.org/Textmode_IDE_development#ansistringification

Don't ever include objects and sysutils in the same unit.

Reply by email

Graeme Geldenhuys
to Marco van de Voort

2009/9/29 Marco van de Voort :

If you want to ansistringify, assume that pstring as a whole is ansistring, and remove all pointers and let ansistrings automatic maintenance work.

Thanks Marco. That's what I did. I read bit more about PString and it seems pretty safe for me to simply replace it with AnsiString. So far so good.

Don't ever include objects and sysutils in the same unit.

Good to know. I'm converting all Objects types to Class types too.

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Reply by email