Discussions related to Visual Prolog
Martin Meyer
VIP Member
Posts: 328
Joined: 14 Nov 2002 0:01

Debug File Flag

Unread post 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
Regards
Martin
User avatar
Thomas Linder Puls
VIP Member
Posts: 1398
Joined: 28 Feb 2000 0:01

Unread post 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.
Regards Thomas Linder Puls
PDC
Martin Meyer
VIP Member
Posts: 328
Joined: 14 Nov 2002 0:01

Unread post 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
Martin
User avatar
Thomas Linder Puls
VIP Member
Posts: 1398
Joined: 28 Feb 2000 0:01

Unread post 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.
Regards Thomas Linder Puls
PDC
Martin Meyer
VIP Member
Posts: 328
Joined: 14 Nov 2002 0:01

Unread post by Martin Meyer »

Yes Thomas, I am used to define a constant debug in main.cl 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.

Regards
Martin
Paul Cerkez
VIP Member
Posts: 106
Joined: 6 Mar 2000 0:01

Unread post 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.
AI Rules!
P.
User avatar
Jan de Lint
VIP Member
Posts: 83
Joined: 6 Mar 2000 0:01

Unread post 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.
]an
Post Reply