walter01
19th December 2008, 11:52
Hi,

I have added logging lines to my report script and I want to use conditional compiling of the logging functions. How do I set this up ? I have added the code below but it doesn't matter if I change the LOGGING value. The logging is always compiled. Can someone tell me what I'm doing wrong ?


declaration:

#define LOGGING 1

before.program:
xlog.init()

after.program:
xlog.close()

detail.1:
before.layout:
...
...
xlog.regel("I", "msg67 Orderline blocked." & str$(tdsls041.pono))
...
...

functions:
function xlog.init()
{
#ifdef LOGGING
...
...
setup logfile code
...
...
#endif
}

function xlog.regel(string log.code(1), string log.tekst(150) )
{
#ifdef LOGGING
...
...
write a logfile record code
...
...
#endif
}

function xlog.close()
{
#ifdef LOGGING
...
...
close logfile code
...
...
#endif
}


thanks,

Walter

zardoz
19th December 2008, 13:14
If you want to use the #ifdef directives, then LOGGING is a parameter that you must define outside the script, not a variable of the program.
You have to use the parameters in the script header in tools, adding:
-DLOGGING

walter01
19th December 2008, 14:14
Thanks Zardos,

That did it !
I guess I read the helpfile to quickly.

Walter

günther
22nd December 2008, 09:42
Hi Walter,

I just want to add one thing: You must be aware that even if you define LOGGING=0, you are allways calling an empy function. Normally, that won't be a problem, but in some other cases it might be. So there could be less code in the object file and a better runtime behaviour if you check this way:


declaration:

#define LOGGIGNG 1

#if LOGGING
# define XLOG(x) x
#else
# define XLOG(x) | empty
#endif

before.program:
XLOG( xlog.init() )

after.program:
XLOG( xlog.close() )

detail.1:
before.layout:
...
...
XLOG( xlog.regel("I", "msg67 Orderline blocked." & str$(tdsls041.pono)) )
...
...

functions:

#if LOGGIN

function xlog.init()
{
...
...
setup logfile code
...
...
}

function xlog.regel(string log.code(1), string log.tekst(150) )
{
...
...
write a logfile record code
...
...
}

function xlog.close()
{
...
...
close logfile code
...
...
}

#endif