Page 1 of 1

Named Enums

Posted: Sat Jun 05, 2010 10:28 am
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.

Re: Named Enums

Posted: Sat Jun 05, 2010 2:56 pm
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

Re: Named Enums

Posted: Sat Jun 05, 2010 11:31 pm
by DoubleDutch
This is a good idea.

Re: Named Enums

Posted: Sun Jun 06, 2010 12:32 am
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

Re: Named Enums

Posted: Sun Jun 06, 2010 10:14 am
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.

Re: Named Enums

Posted: Sun Jun 06, 2010 12:08 pm
by DoubleDutch
Foz: I like this idea too.

Re: Named Enums

Posted: Sun Jun 06, 2010 2:11 pm
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:

Re: Named Enums

Posted: Sun Jun 06, 2010 2:46 pm
by skywalk
@Josh - you are correct, I was being lazy lumping in the autocomplete stuff with your request. :)

Re: Named Enums

Posted: Sun Jun 06, 2010 4:29 pm
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.

Re: Named Enums

Posted: Sun Jun 06, 2010 6:11 pm
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?

Re: Named Enums

Posted: Sun Jun 06, 2010 6:43 pm
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 ^^

Re: Named Enums

Posted: Sun Jun 06, 2010 6:47 pm
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: