PDA

View Full Version : enumerations?



largo_winch
17-05-2011, 11:21
hello. How I can use "enumerations" in thinbasic? with "type"/"end type" or better using with "equals"? there are any examples to study?
regards, largo

ErosOlmi
17-05-2011, 12:32
Hi largo.

What do you man by "enumerations"?

If you intend collections (like in OOP), thinBasic cannot have something like that at the moment but we can talk about for future.

If you mean something like having autonumbered equates you can use the construct:

Begin Const
...
End Const


See thinBasic help or online help (http://www.thinbasic.com/public/products/thinBasic/help/html/begin_const_____end_const.htm).

If none of the above, just point me to a programming language that already implements what you are referring to and I will see what I can do for future thinBasic releases.

Let me know.

Ciao
Eros

largo_winch
17-05-2011, 17:11
my intention was I wanted to translate irrlicht wrapper for thinbasic. there are several enumerations (freebasic) "enum's (example: for devices and drivers) and I wasn't sure about that things to fix this for thinbasic. that's all. thanks for your fast reply.
regards, largo


ENUM
[Listenname]
Element1 [= INTEGER Wert]
Element2 [= INTEGER Wert]
Element3 [= INTEGER Wert]
...
END ENUM

ErosOlmi
17-05-2011, 17:55
I will check ENUM in FreeBasic and see if they compare with equates in their use inside code

ReneMiner
05-03-2015, 17:51
since this thread is up already- even if i can not read a message by Marko Marko (http://www.thinbasic.com/community/member.php?1793-Marko-Marko)...


the idea was this - and still desired:
(without knowing it i started similar idea-thread a while ago here: http://www.thinbasic.com/community/showthread.php?12467-enumerating-thoughts )



'current working syntax:

Type t_myColors
IndianRed As Long ' all UDT-members are same type for sure
LightCoral As Long ' long in this case
Salmon As Long
'...
End Type

Global myColor as t_myColors

With myColor
.IndianRed = &H5C5CCD
.LightCoral = &H8080F0
.Salmon = &H7280FA
'...
End With

' "myColor-Enumeration" is ready for use now


the desired syntax:


Enumerate myColor As Long
IndianRed Value &H5C5CCD
LightCoral Value &H8080F0
Salmon Value &H7280FA
'...
End Enumerate


now myColor should be somewhat like a dimensioned and all assigned UDT
without having to Dim a variable of this type (indeed its impossible -there's only ONE!)
so now can use for example


whatever.SetColor(myColor.Salmon) ' all "myColor"-constants are nicely grouped now

values are constant and udt-members are all of of same type - as an array mostly

-nevermind that the Enumeration equals TB-%RGB-Equates- just an example what for it is used...

thinkeable too:


Begin Const
Enum %myColor As Long
IndianRed Value &H5C5CCD

'...

End Enum
End Const

whatEver.SetColor(%myColor.MidnightBlue)