Converting enum elements
Hello. As the title says most of it, is there any way to convert enum elements to a certain string? I did search a lot before coming to ask here, even in other Pawn forums. In fact I've been hassling with this for more than 4 straight hours. Unfortunately I couldn't find anything helpful at all. After some time of researching I thought a pre-processor functionality from C (which I suppose is missing in Pawn) called "stringification" would help me, but that was something completely distinct and I realized it much later.
If you don't understand, here's what I mean: Code:
That's not something natives can do so I'm counting on a hackish macro-function, if even possible... |
Re: Converting enum elements
I might not fully understand what you're trying to do, but what about this?
PHP Code:
|
Re: Converting enum elements
The enumerator members are only integer constants, the name of the variable cannot be converted to a string, to my knowledge at least. You'd need to size an array using the enumerator name and place the items in the array in the same order.
PHP Code:
|
Re: Converting enum elements
Bugsy that's not what I need because that's hard-coded. The idea behind is to iterate through an enum's valid (0 - N) members and check if their name matches with a certain string. I heard Pawn for SA:MP has actually a stringification macro-function which could in theory come handy, but that's a custom feature. I just got my hands into the compiler we use and already figured out the part macro-definitions are handled. Because it's late mid-night now rest is to be seen & possibly modified tomorrow.
|
Re: Converting enum elements
I had a feeling, being it was the most obvious solution. Though, I'm not sure it's worth the hassle to modify the compiler to handle this. Why does the string array not satisfy what you're trying to do? If the string matches the enum constant, how is it any different?
|
| All times are GMT -4. The time now is 17:07. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.