Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Symbol 'NewStr' is Deprecated

143 views
Skip to first unread message

Mark E. Moss

unread,
Sep 15, 2004, 5:26:49 PM9/15/04
to
Help


I compiled an old application and I am getting two Deprecated
messages

Symbol 'NewStr' is deprecated
Symbol 'DisposeStr' is deprecated

What should I use instead and where is it documentated?


Mark Moss


Kurt Barthelmess [TeamB]

unread,
Sep 15, 2004, 7:24:22 PM9/15/04
to
"Mark E. Moss" <mark...@ix.netcom.com> wrote:

> Symbol 'NewStr' is deprecated

> What should I use instead and where is it documentated?

You probably want to reevaluate what the code here is doing. You are
probably playing with pointers to strings (It's not clear whether they
are long or short strings from the info provided), which is always a
risky business given Delphi's string reference management (for long
strings) and the limited capabilities and inefficiencies of short
strings.

Neither I not the compiler can give much guidance beyond that with the
info provided.

Good luck.

Kurt

Mark Moss

unread,
Sep 15, 2004, 7:59:33 PM9/15/04
to
Kurt

Below is a section of code that has both the NewStr and Unassigned
in it.

Mark Moss

----------------------------------------------------------------------

procedure TfrmMain.RetrieveOutlookFolders;
procedure LoadFolder(ParentNode: TTreeNode; Folder: OleVariant);
var
i: Integer;

node: TTreeNode;
begin
for i := 1 to Folder.Count do
begin
node := tvFolders.Items.AddChildObject(ParentNode,
Folder.Item[i].Name,

TObject(LongInt(NewStr(Folder.Item[i].EntryID))));
LoadFolder(node, Folder.Item[i].Folders);
end;
end;

var
outlook, NameSpace: OLEVariant;

begin
outlook := CreateOleObject('Outlook.Application');
NameSpace := outlook.GetNameSpace('MAPI');
LoadFolder(nil, NameSpace.Folders);
outlook := UnAssigned;
end;

Mike Shkolnik

unread,
Sep 16, 2004, 12:44:07 AM9/16/04
to
Mark,

you must use the PChar instead

--
With best regards, Mike Shkolnik
E-mail: mshk...@scalabium.com
WEB: http://www.scalabium.com

"Mark E. Moss" <mark...@ix.netcom.com> wrote in message
news:4148B399...@ix.netcom.com...

Mark Moss

unread,
Sep 16, 2004, 12:20:07 PM9/16/04
to
Mike

What do you do with the DisposeStr though.

and would I replace the first line with the sceond on?

node := tvFolders.Items.AddChildObject(ParentNode,
Folder.Item[i].Name, TObject(LongInt(NewStr(Folder.Item[i].EntryID))));

node := tvFolders.Items.AddChildObject(ParentNode,
Folder.Item[i].Name, TObject(LongInt(PChar(Folder.Item[i].EntryID))));

I am sorry but I have been away from Delphi for about a Year so I'am
kind of rusty.

Thanks

Mark Moss


"Mike Shkolnik" <mshkol...@ukr.net> wrote in message
news:4149...@newsgroups.borland.com...

Peter Below (TeamB)

unread,
Sep 16, 2004, 1:13:59 PM9/16/04
to
In article <4148d76f$1...@newsgroups.borland.com>, Mark Moss wrote:
> Below is a section of code that has both the NewStr and Unassigned
> in it.
>
> Mark Moss
>
> procedure TfrmMain.RetrieveOutlookFolders;
> procedure LoadFolder(ParentNode: TTreeNode; Folder: OleVariant);
> var
> i: Integer;
>
> node: TTreeNode;
> begin
> for i := 1 to Folder.Count do
> begin
> node := tvFolders.Items.AddChildObject(ParentNode,
> Folder.Item[i].Name,
>
> TObject(LongInt(NewStr(Folder.Item[i].EntryID))));

So you are using it to copy a zero-terminated string to another one to store
it into the Node.Data property. That is in fact the best way to store a
string into such a property without falling afoul of the Ansistring
reference counting.

Keep this code, it is OK. As long as you do not intend to port it to .NET,
that is <g>.


--
Peter Below (TeamB)
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be


0 new messages