Value2ConstantDebug

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
User avatar
Didelphodon
PureBasic Expert
PureBasic Expert
Posts: 450
Joined: Sat Dec 18, 2004 11:56 am
Location: Vienna - Austria
Contact:

Value2ConstantDebug

Post by Didelphodon »

Value2ConstantDebug is a tiny little include which makes your debuging lifes easier. As soon as you're dealing with issues in event-handling you'll find out that those anonymous numbers and values are unnecessarily complicating everything and hindering your progress.

That's where/when Value2ConstantDebug comes in handy. It takes a value (f.i. of an event) and converts it back to the according constant-name.

Furthermore Value2ConstantDebug adds a smart feature as suppression of redundant values.


How to use it? Well, it's just like an enhanced Debug statement. Take a look at this example:

Code: Select all

v2cd_Debug(EventType(), "#pb_eventtype_,#pb_anti", #True, #True)
According to the procedure's (v2cd_Debug) declaration ...

Code: Select all

v2cd_Debug(value.i, constantNameFilter.s = "", suppressRedundancies.b = #True, printIfNotFound.b = #True)
... this would re-convert the EventType()-returnvalue to a (all) constant-name(s) starting with "#pb_eventtype_" or "#pb_anti".
Furthermore any redundancies would be suppressed, though counted and printed as one message when the value changes.
If no fitting constant-definition is found the value still gets printed in its original form.

Why the argument "constantNameFilter"?
Well, there are some specific values that are shared through lots of constants (names). So which would be the fitting one? The easy answer is "only YOU can", and therefore you're helping yourself by filtering out the right ones by defining the contant-name beginnings you'd like to get.

An empty "constantNameFilter" brings up only the original values, though the redundancy suppression feature still can be used.

Setting "constantNameFilter" to "#" will bring you *all* known constant-names for the according value - these might be many.

However, I was once fed up with dealing with event-issues and so I coded this tiny tool. I hope that it will also be useful to you guys.

Download

EDIT: This should work on Linux and Mac OS, too - but I didn't test it on the latter, yet.

Cheers,

Didelphodon.
Last edited by Didelphodon on Wed Feb 25, 2015 11:21 am, edited 1 time in total.
Go, tell it on the mountains.
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: Value2ConstantDebug

Post by c4s »

This looks really useful, thank you!

I didn't test it right now but I already have an idea/feature request. ;-)
As I can see from the source the defining of the constants takes most of the place. Wouldn't it be possible to automatically scan/retrieve those values? (from "PureBasic\Residents\" I'd say) This way it would be possible to debug Windows own and similar constants as well. Maybe even those self-defined ones from the source code?!
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
User avatar
Didelphodon
PureBasic Expert
PureBasic Expert
Posts: 450
Joined: Sat Dec 18, 2004 11:56 am
Location: Vienna - Austria
Contact:

Re: Value2ConstantDebug

Post by Didelphodon »

c4s wrote:This looks really useful, thank you!

I didn't test it right now but I already have an idea/feature request. ;-)
As I can see from the source the defining of the constants takes most of the place. Wouldn't it be possible to automatically scan/retrieve those values? (from "PureBasic\Residents\" I'd say) This way it would be possible to debug Windows own and similar constants as well. Maybe even those self-defined ones from the source code?!
Thx for that point. Initially I also thought of such kind of comfort but chose to have a quick'n'dirty way I could work with. However, that decision isn't carved in stone in any way. I'll take a look at it when I have time for. In the meantime, if you have any relevant modifications let me know and I'd be glad if you share them with me so I can add them to the download-version.

Cheers,
Didel.
Go, tell it on the mountains.
MachineCode
Addict
Addict
Posts: 1482
Joined: Tue Feb 22, 2011 1:16 pm

Re: Value2ConstantDebug

Post by MachineCode »

Didelphodon wrote:Value2ConstantDebug is a tiny little include
"Tiny"? :lol: I almost died when I saw the code after the "police line". :)
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
User avatar
Didelphodon
PureBasic Expert
PureBasic Expert
Posts: 450
Joined: Sat Dec 18, 2004 11:56 am
Location: Vienna - Austria
Contact:

Re: Value2ConstantDebug

Post by Didelphodon »

MachineCode wrote:
Didelphodon wrote:Value2ConstantDebug is a tiny little include
"Tiny"? :lol: I almost died when I saw the code after the "police line". :)
I meant tiny in terms of functionality ... ;-)
Go, tell it on the mountains.
Post Reply