Page 1 of 1

Debug File Flag

Posted: 26 Feb 2015 10:22
by Martin Meyer
Hi Thomas and all,

in Project Settings in the Version Information tab in line File Flags the first flag is named Debug. How to query the flag in a program? I would like to use it in the way:

Code: Select all

#if debug = true #then     ... my add-on code for debugging purposes ... #endif

Posted: 26 Feb 2015 13:41
by Thomas Linder Puls
Visual Prolog does not have "debug" and "release" mode.

The flag you mention controls a value in the version resource which is added to the program when the program is linked.

It is not available at compile time. At run time the program can read its own version resource and behave based on that.

Posted: 26 Feb 2015 14:27
by Martin Meyer
Thx for the info, Thomas!

Maybe you could introduce a new build-in constant in a future release to make the flag available at compile time?

Many regards

Posted: 26 Feb 2015 20:26
by Thomas Linder Puls
Absolutely not.

It is a very conscious decision from our side that there is only one configuration. What you debug is also what will run in release.

But conditional compilation exist and you can of course define your own flag if you insist on several configurations.

Posted: 27 Feb 2015 11:44
by Martin Meyer
Yes Thomas, I am used to define a constant debug in to toggle my self-made debug configuration on/off. The program sections, I am conditionally switching on/off in compilation via the constant, contain predicates, which output the contents of structures (for example collections) through stdIo::write for inspection.

When my program is not working as I expect, I set debug to true and place calls to these predicates at suspect points in my code. Once I have found and corrected the bug, I set debug back to false. The compiler then directs me to every place in the code, where I had inserted an inspection call. So I can remove them quickly.

Usually I start that workflow, when I am not able to locate the cause of a problem by just stepping through the code with the debugger. As yet that's my "best practice", and I have no idea how to do better to omit introducing a secondary configuration.


Posted: 27 Feb 2015 15:00
by Paul Cerkez
back in the "old" days before the built in debugger, I used to do something very similar.

I would create a global constant, then with conditional compilation flags, I would embed troubleshooting statements in my code surrounded by the flag. Then all I had to do was change the global flag's value and all the 'troubleshooting' code with stay out of the final build.

I still do something similar. It is very handy sometimes, especially when troubleshooting logic/sequence problems.

Posted: 2 Mar 2015 11:49
by Jan de Lint
I have something similar, but at run time.
I use a /log flag and when that is on, things like logging will become active.
More run time code but independent of the IDE.