Named Enums

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Josh
Addict
Addict
Posts: 1183
Joined: Sat Feb 13, 2010 3:45 pm

Named Enums

Post by Josh »

it would be fine to have named enums like this:

Code: Select all

Enumeration enumColors
  #ColRed
  #ColGreen
  #ColBlue
EndEnumeration

Procedure Test (Color.enumColor)
  Debug Color
EndProcedure
when i have large pbi files with many procedures, i often don't know, what to do with the parameters. so when i'm writing a call to the procedure from the above example and come to the parameters, a popupmenu show me the possible enums.

edit for better understanding:
so when i'm writing a call to the procedure Test from the above example and come to the parameters, the autocomplete will show me the three items (#ColRed, #ColGreen, #ColBlue) from the named enum.
Last edited by Josh on Sun Jun 06, 2010 7:00 pm, edited 3 times in total.
sorry for my bad english
User avatar
skywalk
Addict
Addict
Posts: 4211
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: Named Enums

Post by skywalk »

I agree. This is a cool and useful feature from the Visual Studio shtuff. :)
It enhances the Autocomplete feature by limiting the contents or prioritizing them to the enum or gadget type.

I would also add the request that gadget specific Flags be forced to the top of the Autocomplete list when in that field of a command.
Some examples:

Code: Select all

\id = ButtonImageGadget(#PB_Any, \X, \Y, \Wd, Ht, ImagesInUse(\imgNr)\hnd, ...User Hits [Ctrl+Space] here...)
;...Autocomplete lists the following...
#PB_Button_Toggle

\id = OpenWindow(wID, \x, \y, \wd, \ht, \Txt, ...User Hits [Ctrl+Space] here...)
;...Autocomplete lists the following...
#PB_Window_BorderLess    
#PB_Window_Invisible     
#PB_Window_Maximize
#PB_Window_MaximizeGadget
#PB_Window_Minimize
#PB_Window_MinimizeGadget
#PB_Window_NoGadgets
#PB_Window_ScreenCentered
#PB_Window_SizeGadget  
#PB_Window_SystemMenu   
#PB_Window_TitleBar      
#PB_Window_Tool          
#PB_Window_WindowCentered
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Re: Named Enums

Post by DoubleDutch »

This is a good idea.
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
Foz
Addict
Addict
Posts: 1359
Joined: Tue Nov 13, 2007 12:42 pm
Location: Manchester, UK

Re: Named Enums

Post by Foz »

Actually, a slight adjustment to the current enum method to automatically add a prefix would be good enough for me:

Code: Select all

Enum Color_
  Red
  Blue
  Green
EndEnum

Procedure GetValue(enumColor)
  Select enumColor
  Case #Color_Red
  Case #Color_Blue
  Case #Color_Green
  EndSelect
EndProcedure
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: Named Enums

Post by c4s »

@skywalk
Really good idea - I like and want it too!
...But better create a new request because it's more a wish for the IDE so that Fred and Freak don't get confused or oversee it.
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Re: Named Enums

Post by DoubleDutch »

Foz: I like this idea too.
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
User avatar
Josh
Addict
Addict
Posts: 1183
Joined: Sat Feb 13, 2010 3:45 pm

Re: Named Enums

Post by Josh »

@ skywalk

why to hit [Ctrl+Space] ? it should be used the same technique, like already used with structures:

Code: Select all

Structure udtColor
  Red.l
  Green.l
  Blue.l
EndStructure

Define Specification.udtColor

Specification\
structures: at the moment i'm writing the backslash, the autocomplete menu opens
named enums: at the moment i'm writing the comma, the autocomplete menu should open. ok, in case of flags, the autocomplete menu has to open again, after flag specific characters like '|'.

that fred and freak have to add the named enums to pb-intern procedures like OpenWindow and so on, is a other chapter :mrgreen:
sorry for my bad english
User avatar
skywalk
Addict
Addict
Posts: 4211
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: Named Enums

Post by skywalk »

@Josh - you are correct, I was being lazy lumping in the autocomplete stuff with your request. :)
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
Josh
Addict
Addict
Posts: 1183
Joined: Sat Feb 13, 2010 3:45 pm

Re: Named Enums

Post by Josh »

@ skywalk

sorry sky, but i don't understand your separat topic Enhanced AutoComplete in the wishlist. its the same, i'm writing here. in case, fred/freak would include named enums, its only a logical conclusion to use this feature in pb own procedures too.
sorry for my bad english
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: Named Enums

Post by c4s »

@ Josh
I said that it would be better to create a new topic because it's just an IDE suggestion and I didn't understand yours. So these named enums are also for the IDE?
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
User avatar
Josh
Addict
Addict
Posts: 1183
Joined: Sat Feb 13, 2010 3:45 pm

Re: Named Enums

Post by Josh »

c4s wrote:So these named enums are also for the IDE?
of course. constants, enums are not necessary for building the exe, like many other things. so this named enums are also only a help for the developer. ok, it would have been better, if i had used autocomplete instead of popupmenue ^^
sorry for my bad english
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Named Enums

Post by ts-soft »

Only for the ide it makes no sense!

Code: Select all

Enumeration Colors
  #MyBlue = 100
  #MyBlack
  #MyRed  
EndEnumeration

Procedure ShowColor(value.Colors); compilererror if parameter out of Colors!
  Debug value
EndProcedure
This make sense for me :wink:
Post Reply