Results 1 to 5 of 5

Thread: enumerations?

  1. #1

    enumerations?

    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

  2. #2
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    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.

    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
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  3. #3
    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

  4. #4
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    I will check ENUM in FreeBasic and see if they compare with equates in their use inside code
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  5. #5
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,530
    Rep Power
    171
    since this thread is up already- even if i can not read a message by 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/s...ating-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)
    
    Last edited by ReneMiner; 05-03-2015 at 18:41.
    I think there are missing some Forum-sections as beta-testing and support

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •