 All right, so I know it's been a while since I've done any of these videos. I've been Rather sick for the past three weeks. It barely eaten I'm feeling better now, but there's been a lot of other stuff going on as well, and I just Priorities, I haven't really had time to get to one of these But I figure this time around let's do a video that Should have been with some of the previous ones that I've been redoing but hasn't never actually got done very well it was sort of included with one of them and they didn't cover the subject very very well at all and With that, I mean enumerations in Ida There's quite a bit more going on with them then first meets the eye Now they are still very simple to use you'd use them the same way you would in any other language there's just a lot of other things that Are useful to point out because they're provided for you in Ida and they're not really provided or are Provided in very obtuse ways in other languages So let's get into this with just defining a really simple enumeration and Let's just print these out. I Think the image thing works With these now as well See this wasn't something that had existed in Ida up until recently You used to have to do the the type and then image and then contain the thing So let's just nope. I'm not doing that stuff And I haven't forgotten any syntax good So we'll just put the second one as well. Well, nope. I do not want to do that I want to do this Okay now Whether or not you see this kind of behavior in any programming language depends on Exactly how that language wants to behave. I have seen some where Printing out the value of the enumeration Gives the actual underlying value whereas it's actually normal in Ida to get the representation of the value which I find much better because that's Really the whole point of using the enumeration. Otherwise you just have a bunch of values Defined and use those instead now Building upon this for a lot of languages it is possible to define the values in line Such as something like that It is a little different in Ida I'm not quite sure how I feel about this being a separate thing. I Sort of lean against it, but regardless this is how you wind up doing it We'll just do so these are just They're normal values anyways because that's how enumerations work starting from the base value it just increments one unless you get specific about it and There's no point in running this again because it won't change anything about this behavior. I just wanted to show that off one other thing before we get into the rather large amount of attributes that enumerations have is that it is also possible to use a little bit of a surprising value for these oh Yep, and I will inevitably have to change this and Because we're going to get an ambiguity. I will have to fall back to this Because otherwise it will confuse it for characters This is actually how the characters are defined in Ida Sort of implicitly though. They're the standard package doesn't actually exist but This is this is how it's done You can use character literals as the representation values in an enumeration I think you can actually mix them too. I've never tried this ever Apparently you can so yeah aside from the I guess text literals the values Things you can use character literals as well now getting into the The attributes that I mentioned Let's I think you can chain these so if we do example first then image example Well, it's just last in an image. So I'll have to change this from second to last I think Yeah, you can chain these Now this is very useful in that if we go and add something into the in here as well We'll just change this to last we're going very literal Because this is an attribute that's calculated by the compiler essentially sometimes by the runtime, but We don't actually need to change anything about the Code because we specified that we want the last value in that enumeration regardless of whatever value that actually is So if your intent is not to get a specific value, but rather get a value at a specific position This is one of the ways to do that Continuing on with that theme Let's add another one in here and I believe this works like example Oh And then we want the second one and then we want the image of it No, no, no, no, I'm thinking the wrong way. So we want not the position of what we're passing but rather the We're we're passing it the Yeah, I think these are backwards in my opinion, but maybe that's just the way I think But there oh Yeah, because this whole thing actually starts from zero So enumerations unlike a lot of the other stuff in Ida are actually zero indexed unless you go in and actually do the representation clause So we can change that here I'm doing this for a reason. We're gonna get into that in just a second, but Yeah, other than me forgetting that nothing should be wrong here. I still am where No What oh cuz I didn't save it. Yeah, okay silly mistake No, we still do that. Oh I know why I know why So this is not the literal value. This is just the index of it So continuing with the whole thing about these being zero indexed regardless of what's in the representation clause here It's zero one two three So this would be the two as far as that's concerned. There is another Similar attribute that I was thinking about As far as I know these are only available under net So be a little cautious with that if you're using the PTC compiler or similar this may not work out This looks up through the enumeration value instead of the enumerations index so a little a Little funky just given that it's the other one has the value thing as well But effectively it's the index not the actual value That should be changed. I can't believe they didn't change that but Yeah another one regarding relative and absolute positions within these is We do and I got to remember exactly how this whole thing works So we do example you know and we want the succeeding ones image Must be a type So that can't be trailing we've got to do this examples seating there The really convenient thing about this is if we change this to four which would not be The next value but rather the next in the in this succession this will Still work There is a similar one called Fred or proceeding that works the exact same way just the proceeding one rather than the succeeding one This is actually mostly it there's one more little thing I want to show off so this was by To change this instead to example of C Oh Yeah So we also need to call the image of that okay So this is basically the counterpart of the Val instead of passing it the The value and then looking up the literal at that that position we're giving it the We're essentially asking it for the position of C. So asking it for what where what the index of it is and Going along with what I've said before with the enumerations being zero indexed oddly zero one two that checks out and And There is a similar counterpoint that's available if you have if you are working with Nat compilers and anything else that may support this I don't again I don't believe that the PTC and other compilers do But this one is you know rat Which will instead get the representation value which should wind up being four And it is See, I believe this is everything relevant to show off if I have missed something just point it out down in the comments And I'll figure out something to do with that, but I Hope this video has been helpful and I know there's quite a bit more to enumerations than that first meets the eye granted, it's not a particularly con complicated subject either though, but it is good to know this stuff that is available for you If you have found this video helpful, please consider giving a thumbs up It helps out quite a bit and also if you like these videos in general consider subscribing YouTube does some funky stuff with subscribers now So if you actually want to get notified you have to also hit the little bell. I don't understand Why is it seems like subscribing should already do that for you anyways, but Yeah, until I can get around to doing another one of these have a good one