SetString

This is the forum for miscellaneous technical/programming questions.

Moderator: 2ffat

Post Reply
AndyPhotosBell
Posts: 4
Joined: Fri May 08, 2020 3:59 am

SetString

Post by AndyPhotosBell »

I'm using C++ Builder 2007

I'm trying to use the SetString function. The help file says it's there in namespace System, but the compiler disagrees and says it's unknown.

I've searched all BCB's include files but cannot find it...

Is there a way to use it?

Andy
rlebeau
BCBJ Author
BCBJ Author
Posts: 1701
Joined: Wed Jun 01, 2005 3:21 am
Location: California, USA
Contact:

Re: SetString

Post by rlebeau »

AndyPhotosBell wrote:I'm trying to use the SetString function. The help file says it's there in namespace System, but the compiler disagrees and says it's unknown.
The documentation is misleading. SetString() is an intrinsic function in the Delphi compiler, so it is not in any namespace at all.
AndyPhotosBell wrote:I've searched all BCB's include files but cannot find it...
Because it does not exist in C++.
AndyPhotosBell wrote:Is there a way to use it?
No. But then again, you don't need SetString() in C++ anyway. AnsiString (and WideString, and UnicodeString in CB2009+) has a constructor that accepts the same parameters that SetString() does, eg:

Code: Select all

AnsiString s;
s = AnsiString(charData, dataLen);
Or simply:

Code: Select all

AnsiString s(charData, dataLen);
Remy Lebeau (TeamB)
Lebeau Software
AndyPhotosBell
Posts: 4
Joined: Fri May 08, 2020 3:59 am

Re: SetString

Post by AndyPhotosBell »

Thanks Remy
Post Reply