Wish [BANano] [SOLVED]- 1.21 Enumeration Initialization Assignments

Discussion in 'B4J Bugs & Wishlist' started by Mashiane, Jan 5, 2019.

Tags:
  1. Mashiane

    Mashiane Expert Licensed User

    Hi there

    I have defined a class to hold some enumeration values, below is one of them

    Code:
    #IgnoreWarnings:12
        
    'create a COLOR class
    Sub Class_Globals
        
    Public AMBER As String
        
    Public BLACK As String
        
    Public BLUE As String
        
    Public BLUEGREY As String
        
    Public BROWN As String
        
    Public CYAN As String
        
    Public DEEPORANGE As String
        
    Public DEEPPURPLE As String
        
    Public GREEN As String
        
    Public GREY As String
        
    Public INDIGO As String
        
    Public LIGHTBLUE As String
        
    Public LIGHTGREEN As String
        
    Public LIME As String
        
    Public ORANGE As String
        
    Public PINK As String
        
    Public PURPLE As String
        
    Public RED As String
        
    Public TEAL As String
        
    Public TRANSPARENT As String
        
    Public WHITE As String
        
    Public NORMAL As String
        
    Public YELLOW As String
    End Sub

    'Initializes COLOR object
    Sub Initialize() As BANanoMaterialColor
        AMBER = 
    "amber"
        BLACK = 
    "black"
        BLUE = 
    "blue"
        BLUEGREY = 
    "blue-grey"
        BROWN = 
    "brown"
        CYAN = 
    "cyan"
        DEEPORANGE = 
    "deep-orange"
        DEEPPURPLE = 
    "deep-purple"
        GREEN = 
    "green"
        GREY = 
    "grey"
        INDIGO = 
    "indigo"
        LIGHTBLUE = 
    "light-blue"
        LIGHTGREEN = 
    "light-green"
        LIME = 
    "lime"
        ORANGE = 
    "orange"
        PINK = 
    "pink"
        PURPLE = 
    "purple"
        RED = 
    "red"
        TEAL = 
    "teal"
        TRANSPARENT = 
    "transparent"
        WHITE = 
    "white"
        NORMAL = 
    ""
        YELLOW = 
    "yellow"
        
    Return Me
    End Sub
    In a master class I have defined..

    Code:
    Dim EnumColor as BANanoMaterialColor
    EnumColor.Initialize
    However calling

    Code:
    Log(EnumColor.GREEN)
    in the main module writes blank in the console.log. I could be doing this wrongly however assumed that it would work or rather its not assigning the values or something. Please have a peek!

    Ta!
     
  2. Eme Fibonacci

    Eme Fibonacci Well-Known Member Licensed User

    Hi, it´s works for me.

    Code:
    Log(EnumColor.GREEN)
    'result - green
    Try clean your project.
     
  3. Eme Fibonacci

    Eme Fibonacci Well-Known Member Licensed User

    Please, why don´t you use this way? (More simple)
    Code:
    Sub Class_Globals
        
    Public AMBER As String = "amber"
       
    'Or Public Const AMBER As String ="amber"
        Public BLACK As String = "black"
        
    Public BLUE As String = "blue"
    End Sub

    Public Sub Initialize
    End Sub
     
  4. Mashiane

    Mashiane Expert Licensed User

    For a B4J project it works fine however for a BANano based project its not working yet. I have found a work around but its dirty by assigning the values in Class_Globals.
    Ta!
     
  5. Mashiane

    Mashiane Expert Licensed User

    The reason is, I want to perhaps do other things on Initialization besides just assigning values but I have also already implemented your suggestion. At times the compiler complains when assigning values in Class_Globals.

    Fact is, due to Initialize is assigning values to the properties, it should work, unless its a design issue inside BANano, if that is the case then, its a learning curve.
     
  6. alwaysbusy

    alwaysbusy Expert Licensed User

    Mashiane likes this.
  7. Mashiane

    Mashiane Expert Licensed User

    Thank you for the positive response. Please note that as people who are new to BANano we are bound to make mistakes and need all the guidance and help we can get to create beautiful things for both the forum and ourselves. Erel has also on numerous occasions referred people back to their code to fix their own errors, its only natural and you also do the same and thanks for your patience and understanding also, it is very much needed.
     
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