CountGadgets(#WindowID)

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Post by traumatic »

Rescator wrote:Hmm!

Code: Select all

Enumeration
#Bla1   ;this starts at 0
#Bla2
#Bla3
#Bla4
#Bla5
#BlahCount ;this would be #Blah5+1, which would be 5 in this case.
EndEnumeration
Err... that's what #PB_Compiler_EnumerationValue is for... ;)
Good programmers don't comment their code. It was hard to write, should be hard to read.
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Post by fsw »

traumatic wrote:
Rescator wrote:Hmm!

Code: Select all

Enumeration
#Bla1   ;this starts at 0
#Bla2
#Bla3
#Bla4
#Bla5
#BlahCount ;this would be #Blah5+1, which would be 5 in this case.
EndEnumeration
Err... that's what #PB_Compiler_EnumerationValue is for... ;)
What about that:

Code: Select all

Enumeration [<constant> [Step <constant>]] 
  #Constant1
  #Constant2 [= <constant>]
  #Constant3
  ...
EndEnumeration #EnumCount
Makes more sense to me...
:)
dracflamloc
Addict
Addict
Posts: 1648
Joined: Mon Sep 20, 2004 3:52 pm
Contact:

Post by dracflamloc »

Also what if you have more than one enumeration.
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Post by fsw »

dracflamloc wrote:Also what if you have more than one enumeration.
I suppose you just use another CountConstant ...

#Gadgets
#SpecialStuff
#DontNeedThisOne
etc.
dracflamloc
Addict
Addict
Posts: 1648
Joined: Mon Sep 20, 2004 3:52 pm
Contact:

Post by dracflamloc »

I meant in response to #PB_Compiler_EnumerationValue
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Post by traumatic »

dracflamloc wrote:I meant in response to #PB_Compiler_EnumerationValue
What I meant was that you don't have to actually save the last enumeration
count to a dedicated constant as #PB_Compiler_EnumerationValue already
does exactly that. Hence "#BlahCount" is obsolete.

I'm aware of the fact this may not help with your actual problem though.
Good programmers don't comment their code. It was hard to write, should be hard to read.
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

The problem with the "PB_Compiler_EnumerationValue is it store only the last enumeration value, which means than:

1) if you have several enumeration, it will work only for the last one
2) if your enumeration isn't sequencial it will store the last value, and not the count.

The suggestion with the #Count contant at the end of the enumeration looks good to me.
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Post by traumatic »

Fred wrote:2) if your enumeration isn't sequencial it will store the last value, and not the count.
Ah yes, true! :oops:
Good programmers don't comment their code. It was hard to write, should be hard to read.
Post Reply