SetString

This is the forum for miscellaneous technical/programming questions.

Moderator: 2ffat

SetString

Postby AndyPhotosBell » Fri May 08, 2020 4:04 am

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
AndyPhotosBell
 
Posts: 4
Joined: Fri May 08, 2020 3:59 am

Re: SetString

Postby rlebeau » Fri May 08, 2020 12:25 pm

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
User avatar
rlebeau
BCBJ Author
BCBJ Author
 
Posts: 1669
Joined: Wed Jun 01, 2005 3:21 am
Location: California, USA

Re: SetString

Postby AndyPhotosBell » Sat May 09, 2020 12:47 pm

Thanks Remy
AndyPhotosBell
 
Posts: 4
Joined: Fri May 08, 2020 3:59 am


Return to Technical

Who is online

Users browsing this forum: Google [Bot] and 26 guests