Page 1 of 1

SetString

PostPosted: Fri May 08, 2020 4:04 am
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

Re: SetString

PostPosted: Fri May 08, 2020 12:25 pm
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);

Re: SetString

PostPosted: Sat May 09, 2020 12:47 pm
by AndyPhotosBell
Thanks Remy