[Gambas-user] enum example
Tobias Boege
taboege at ...626...
Sun Sep 15 16:56:12 CEST 2013
On Sat, 14 Sep 2013, wally wrote:
> Hi
>
> is there a selfexplaining, simpleand clear examplecode available using ENUM ?
> The docs example are not sufficient for my weak head.
>
Really? You use Enum as a more convenient way to declare integer constants:
---
' The file permission numerical constants
Private Const PERM_EXEC As Integer = 1
Private Const PERM_WRITE As Integer = 2
Private Const PERM_READ As Integer = 4
---
simply becomes
---
Private Enum PERM_EXEC = 1, PERM_WRITE = 2, PERM_READ = 4
---
with the additional ability to have implicit sequences:
---
' Counting
Private Const Zero As Integer = 0
Private Const One As Integer = 1
Private Const Two As Integer = 2
---
will be
---
Private Enum Zero, One, Two
---
The first value, if not explicitely given, defaults to 0. The n+1-st value
becomes the n-th value plus 1.
Please, make your own example code of it if you want...
Regards,
Tobi
More information about the User
mailing list