Join 34,000+ subscribers and receive articles from our
blog about software quality, testing, QA and security.

Some example in C++Builder 2k6


#1

How can add paramter in a string ?

usually with delphi version I can Do

SiMain.LogDebug(‘something %d’,[value]);

I try equivalent C++

SiMain->LogDebug(“something %d”,value);

but does not work.

I need to create an external TVarRec all times ?

Thanks
Ing Giuseppe Monteleone


#2

Hello Giuseppe,

you need to pass an explicit TVarRec argument to the LogDebug function when using a format string and array. This is similar to the behavior of the standard Format routine of Borland C++.

Fortunately, there is a C++ macro makes this a bit easier. It is called OPENARRAY and takes two arguments. The first is the array type (in our case TVarRec) and the second is the array itself.

So, when calling LogDebug with a format string, you can call it like this:

SiMain->LogDebug(“something %d”, OPENARRAY(TVarRec, (value)));

By the way, the SmartInspect installation comes with a set of live templates for BDS 2006 (including C++). Among others, there are templates for the functions which take a format string (LogDebug, LogVerbose etc.). For installation help, please have a look at our templates knowledge base article:

http://www.gurock.com/support/kb/9/

After installing the templates, you can enter “sidebf” in the code editor and expand this template by pressing Strg+J.


#3

Hello Giuseppe,

Do you have an C++Builder example? I can’t get it working at all… When including;

#include “SiAuto.hpp”

A lot of error massages appear… (I’m using C++Builder 2010 in Rad studio 2010)

Regards,

Roland Beuker

[quote=Giuseppe Monteleone]How can add paramter in a string ?

usually with delphi version I can Do

SiMain.LogDebug(‘something %d’,[value]);

I try equivalent C++

SiMain->LogDebug(“something %d”,value);

but does not work.

I need to create an external TVarRec all times ?

Thanks
Ing Giuseppe Monteleone[/quote]