strnew replacement?

General TRichView support forum. Please post your questions here
Post Reply
toolwiz
Posts: 150
Joined: Wed Nov 30, 2005 3:27 am

strnew replacement?

Post by toolwiz »

In D2007, it says that 'strnew' is deprecated. Unfortunately, the help doesn't give any suggestions on what to replace it with.

It's used in lots of the routines here that deal with item tags.

Is there something else to use that's equivalent and not deprecated?

-David
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

It cannot be replaced when working with TRichView tags.
Do not worry, it still works and will never be removed from Delphi, otherwise it will break a lot of existing code.
Pieter Zijlstra
Posts: 42
Joined: Sat Oct 08, 2005 3:56 pm
Location: The Netherlands
Contact:

Post by Pieter Zijlstra »

This is a little stange AFAIK StrNew is not deprecated but NewStr is. But NewStr is not used in RichView. :?
toolwiz
Posts: 150
Joined: Wed Nov 30, 2005 3:27 am

Post by toolwiz »

Pieter Zijlstra wrote:This is a little stange AFAIK StrNew is not deprecated but NewStr is. But NewStr is not used in RichView. :?
That's funny ... I'm seeing both of them used throughout RV code. (Do a Find In Files for both of 'em and it finds both.) I didn't realize there were both StrNew and NewStr. So if I use StrNew, that's ok?

-David
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

NewStr() is never used in RichView code. But some functions have parameters named NewStr.
And yes, Pieter is right, StrNew is not deprecated. There is no reason why function allocating a new string on the heap should be deprecated.
Pieter Zijlstra
Posts: 42
Joined: Sat Oct 08, 2005 3:56 pm
Location: The Netherlands
Contact:

Post by Pieter Zijlstra »

So if I use StrNew, that's ok?
No problem and even NewStr is not a direct problem if you can live with some compiler hints (these can be switched as well).
It usually means that it will not be maintained in future versions, but also quite often that there is a (sometimes better) replacement in another unit.
Some functions are depecrated for a couple of versions now and are still present in Delphi's source code.
toolwiz
Posts: 150
Joined: Wed Nov 30, 2005 3:27 am

Post by toolwiz »

I've run into several deprecated functions. The sad part is that it's not mentioned in the help for them, and there's no practical way to find what function should be used to replace them. (No "See Also" to similar functions.)

-David
Pieter Zijlstra
Posts: 42
Joined: Sat Oct 08, 2005 3:56 pm
Location: The Netherlands
Contact:

Post by Pieter Zijlstra »

True, most of the time I look them up in the source, usually that will give you a hint to look elsewhere or sometimes a comment why it was deprecated and what the new function is (thinking of FileAge at the moment but that one is documented in the help also).
Are you using any deprecated function/procedure at the moment?
toolwiz
Posts: 150
Joined: Wed Nov 30, 2005 3:27 am

Post by toolwiz »

Besides this one, just a component or two in the Raize Components 4 library. But that's different.

-David
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

As for NewStr, it was deprecated already in Delphi2. Probably this function was useful in ancient times, when pascal had only fixed length strings.
Post Reply