[Wish] Enum type

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.
 

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
 

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.
 

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:

tchart

Well-Known Member
Licensed User
LucaMs is your tool still available? I get a 404 when I try to download it.
 

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?).
 
Top