Archicad C++ API
About Archicad add-on development using the C++ API.
SOLVED!

ACAPI_WrieReport Format

poco2013
Mentor
My add on uses a Alert message via the WriteReport function. I want to format the output message using some embedded variables. but the place holder %s does not seem to work for UniStrings. does work for %f & %d.

AS in:
GS:: UniString str = 'something';
ACAPI_WriteReport ( "message is  %s" , true,  str ); // does not work. returns no conversion error.
however, i can use str directly without a conversion if no format place holder is used. Is there a solution or a conversion?
Gerry

Windows 11 - Visual Studio 2022; ArchiCAD 27
1 ACCEPTED SOLUTION

Accepted Solutions
Solution
Tibor Lorantfy
Graphisoft Alumni
Graphisoft Alumni
poco2013 wrote:
Is there a solution or a conversion?
Use the ToCStr method of GS::UniString:
GS::UniString str = "something";
ACAPI_WriteReport ("message is %s", true, str.ToCStr ().Get ());

View solution in original post

3 REPLIES 3
leilei
Enthusiast
Hi,
I use this:

GS::UniString successexport;
successexport +="hello";
successexport +="world";
ACAPI_WriteReport(successexport,true);
Solution
Tibor Lorantfy
Graphisoft Alumni
Graphisoft Alumni
poco2013 wrote:
Is there a solution or a conversion?
Use the ToCStr method of GS::UniString:
GS::UniString str = "something";
ACAPI_WriteReport ("message is %s", true, str.ToCStr ().Get ());
poco2013
Mentor
Thanks all and thanks Tibor -- I was missing the get() part of ToCstr()
Gerry

Windows 11 - Visual Studio 2022; ArchiCAD 27