It is currently Wed May 22, 2013 11:49 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Value2ConstantDebug
PostPosted: Thu Sep 08, 2011 9:09 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat Dec 18, 2004 11:56 am
Posts: 277
Location: TPM
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:
v2cd_Debug(EventType(), "#pb_eventtype_,#pb_anti", #True, #True)


According to the procedure's (v2cd_Debug) declaration ...

Code:
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.

_________________
Go, tell it on the mountains.


Top
 Profile  
 
 Post subject: Re: Value2ConstantDebug
PostPosted: Thu Sep 08, 2011 10:03 am 
Offline
Addict
Addict

Joined: Thu Nov 01, 2007 5:37 pm
Posts: 1565
Location: Germany
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?!


Top
 Profile  
 
 Post subject: Re: Value2ConstantDebug
PostPosted: Thu Sep 08, 2011 10:18 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat Dec 18, 2004 11:56 am
Posts: 277
Location: TPM
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.


Top
 Profile  
 
 Post subject: Re: Value2ConstantDebug
PostPosted: Thu Sep 08, 2011 12:19 pm 
Offline
Addict
Addict

Joined: Tue Feb 22, 2011 1:16 pm
Posts: 1459
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!


Top
 Profile  
 
 Post subject: Re: Value2ConstantDebug
PostPosted: Thu Sep 08, 2011 12:25 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat Dec 18, 2004 11:56 am
Posts: 277
Location: TPM
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye