[Wish] Enum type

Discussion in 'Bugs & wishlist' started by NeoTechni, May 12, 2012.

  1. NeoTechni

    NeoTechni Well-Known Member Licensed User

    In VB there's something called an enum type. It's really just a long.

    VB example:
    Public enum DEMONAME
    demoval
    demoval2
    demoval3=4
    demoval4
    end enum

    B4A example:
    enum DEMONAME(demoval,demoval2,demoval3=3,demoval4)

    It would declare demoval,demoval2,demoval3,demoval4 as longs with the values: demoval=0, demoval=1, demoval3=4, demoval=2

    And whenever you start typing in a parameter or select case of that value, the intellisense dropdown would be filled with those values.
     
    icefairy333, Dave O and joseluis like this.
  2. Jost aus Soest

    Jost aus Soest Active Member Licensed User

    Yes, that would be nice.

    Till it's coming you could use a code module (e. g. DEMONAME) with Int-vars (e. g. demoval, demoval2, demoval3, demoval4) to have a similar experience (but of course without intellisense help for the enum type).

    Remember: VB-Long ~ B4A-Int
     
  3. Woinowski

    Woinowski Active Member Licensed User

  4. Woinowski

    Woinowski Active Member Licensed User

    +1

    :D I like that
     
  5. marcel

    marcel Active Member Licensed User

    + 2 :d
     
  6. jalle007

    jalle007 Active Member Licensed User

    yes we like enum type :sign0137:
     
  7. Joe_L

    Joe_L Member Licensed User

    +5 Essential.
    The workaround using instances of types is seriously painful when shared across multiple code modules and especially when they get larger - I'm trying to deal with dozens of enums some of which have 30 to 50 members.
     
  8. ivan.tellez

    ivan.tellez Active Member Licensed User

    +1

    Really useful
     
  9. Bobi

    Bobi Member Licensed User

  10. LucaMs

    LucaMs Expert Licensed User

    Also the constants would be very useful.

    I think that implementing Enums and Constants is particularly difficult; otherwise, Erel certainly would have done from the earliest versions of B4A.

    You can implement a sort of Enum using classes.

    I have developed (right now!) a small and careless tool which allows you to create an "enum" class.

    I used B4J, so it can be installed almost anywhere.

    The problem is that it takes up about 1.671kb (zipped) so I can not attach it.
    (Source code 8k, layout 3k, compiled 1.821kb! :))


    A solution to this, Erel? [P.S. I do not have clouds]


    lm Enum Class Builder.gif

    Two notes:
    1) the code is automatically copied to the clipboard:
    2) I write a lot faster than it looks in the gif :D


    Maybe I solved (I created an account. I hope that the file is available ... and that only it is available :)).

    dropbox link
     
    Last edited: Nov 16, 2015
    JordiCP, JohnD and JakeBullet70 like this.
  11. JakeBullet70

    JakeBullet70 Well-Known Member Licensed User

  12. LucaMs

    LucaMs Expert Licensed User

    I just used it and was helpful :):

    upload_2014-11-7_9-38-30.png


    Code:
    <omissis> = Employee.enumErrorDisplayMode.MSG
    ...
    <omissis> = Employee.enumErrorDisplayMode.Log
     
    Mashiane and thedesolatesoul like this.
  13. swissmade

    swissmade Active Member Licensed User

    Thanks for Sharing
     
    LucaMs likes this.
  14. LucaMs

    LucaMs Expert Licensed User

  15. tchart

    tchart Active Member Licensed User

    LucaMs is your tool still available? I get a 404 when I try to download it.
     
  16. LucaMs

    LucaMs Expert Licensed User

  17. tchart

    tchart Active Member Licensed User

    Thanks LucaMs
     
  18. LucaMs

    LucaMs Expert Licensed User

    upload_2018-7-20_5-29-18.png

    Right; but this is not a new discussion/question, I just have to write:

    Nice and useful, thanks @LucaMs :D




    (about 4 years ago :(:(:(. At that time b4x did not even have constants; and b4j did not have its classic b4x Designer, only Scene Builder!. Perhaps not even Regions).


    It's time for b4x enums (impossible?).
     
  19. Erel

    Erel Administrator Staff Member Licensed User

  20. LucaMs

    LucaMs Expert Licensed User

    This is not what I meant; I was crying thinking that almost 4 years have already passed :(:(:(:)
     
    Erel likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice