1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

Referencing to Enums

Discussion in 'Programming' started by KorbohneD, Jan 7, 2019.

  1. KorbohneD

    KorbohneD Member

    Joined:
    Oct 15, 2017
    Posts:
    11
    Quick Question Guys.

    In my current project I have written a text file translator that turns text file code into real code.

    Now the problem is, in the program, I have a bunch of enums, one in particular describing material. And of course I want to tell the textfile, which material it should give to the translator.
    Is there any way to translate a string into an enum code?

    Like I have this code here:

    Code:
    enum material {
       stone;
       wood;
       iron
    }
    textfile_variable = stone;
    
    material_to_use = material.textfile_variable
    
    Something like above?
    I am really clueless what to do.
    Any help is appreciated.

    Sincerely,
    KorbohneD
     
  2. Taddio

    Taddio Member

    Joined:
    Nov 16, 2018
    Posts:
    463
    Not quite sure I got what you want exactly, correct me if I didn't understood correctly
    Do you want
    Code:
    enum material {
       stone,
       wood,
       iron,
    }
    textfile_variable.material = stone;
    
    ?

    Like I said, not so sure what you were asking, let me know if that's not it, I'll see what I can do
     
  3. KorbohneD

    KorbohneD Member

    Joined:
    Oct 15, 2017
    Posts:
    11

    That code you posted doesn't make any more sense.
    I have a text file, where I state an enum.
    And I need that statement translated, so I can reference a real enum that I have in my code.
     
  4. Taddio

    Taddio Member

    Joined:
    Nov 16, 2018
    Posts:
    463
    Why not simply create an unused script and state your enums in there (they will be inittialized even if no one calls the script, neat feature) instead of going through the hassle of dealing with external files?
     

Share This Page

  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