#PB_Any query

Just starting out? Need help? Post your questions and find answers here.
Foz
Addict
Addict
Posts: 1359
Joined: Tue Nov 13, 2007 12:42 pm
Location: Manchester, UK

#PB_Any query

Post by Foz »

I know that you can specify the same id for a window and a gadget, however, if I use #PB_Any for both windows and gadgets, will the numbers generated ever overlap, or will they be unique?
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: #PB_Any query

Post by srod »

I am pretty sure they would be unique because I am reasonably sure that #PB_Any returns a pointer (for internal PB use).
I may look like a mule, but I'm not a complete ass.
Foz
Addict
Addict
Posts: 1359
Joined: Tue Nov 13, 2007 12:42 pm
Location: Manchester, UK

Re: #PB_Any query

Post by Foz »

I was also thinking on the same lines. I do hope so! Fred? Freak? Please pipe up :D
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8452
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: #PB_Any query

Post by netmaestro »

What difference does it make? Creating window 0 and gadget 0 and image 0 in the same program presents no problems - why would identical #PB_Any values for different object types be a concern?
BERESHEIT
Foz
Addict
Addict
Posts: 1359
Joined: Tue Nov 13, 2007 12:42 pm
Location: Manchester, UK

Re: #PB_Any query

Post by Foz »

Because I'm building a unique id list, and I want to know if I have to roll my own id generator, or if the #PB_Any will do it regardless.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8452
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: #PB_Any query

Post by netmaestro »

afaik #PB_Any is a constant with a value of -1. To use the #PB_Any generator you'd have to actually create an object, no? What, then free it? Seems simpler to use a map. A map enforces uniqueness and it's fast.
BERESHEIT
Foz
Addict
Addict
Posts: 1359
Joined: Tue Nov 13, 2007 12:42 pm
Location: Manchester, UK

Re: #PB_Any query

Post by Foz »

You misunderstand, it's not for maps - it's for a hierarchical tree building, if I have a window and a gadget of the same id, then working out who the children are or who the parent is will get very awkward.

As I said - if using #PB_Any will get me a unique value regardless if it's assigned to a window or a gadget, then I'll just use that, otherwise, I'll use my own unique id generator. I just need to know if I am going to be doing that or not.
Matt
Enthusiast
Enthusiast
Posts: 447
Joined: Sat May 21, 2005 1:08 am
Location: USA

Re: #PB_Any query

Post by Matt »

Nevermind
Last edited by Matt on Sun Dec 06, 2009 6:04 pm, edited 1 time in total.
User avatar
nco2k
Addict
Addict
Posts: 1344
Joined: Mon Sep 15, 2003 5:55 am

Re: #PB_Any query

Post by nco2k »

you are wrong. :wink:

c ya,
nco2k
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
Matt
Enthusiast
Enthusiast
Posts: 447
Joined: Sat May 21, 2005 1:08 am
Location: USA

Re: #PB_Any query

Post by Matt »

Can you correct me? Cause then I don't know :P
User avatar
Arctic Fox
Enthusiast
Enthusiast
Posts: 609
Joined: Sun Dec 21, 2008 5:02 pm
Location: Aarhus, Denmark

Re: #PB_Any query

Post by Arctic Fox »

This post by freak may be of interest
http://www.purebasic.fr/english/viewtop ... 16#p284316
Foz
Addict
Addict
Posts: 1359
Joined: Tue Nov 13, 2007 12:42 pm
Location: Manchester, UK

Re: #PB_Any query

Post by Foz »

Ahhh perfect! Thanks Arctic Fox, the first line confirmed what I and srod suspected - the values are indeed memory addresses, therefore I can guarantee that they will be unique :D
Post Reply