Get Constant Name?

Blitz3D Forums/Blitz3D Programming/Get Constant Name?

RustyKristi(Posted 2016) [#1]
Is it possible to get CONST variable name based on value?


Kryzon(Posted 2016) [#2]
The purpose of Const is just to give a name to a value so it's easier to read. I think the Const names in your code are just replaced by their values before it is compiled.

If you need to have a relation between "key" and "value", maybe a hash algorithm.
In the code archives I only found a Map: http://www.blitzbasic.com/codearcs/codearcs.php?code=2574
But a hash should be faster.

As a string parameter to a function, you input the value of the const and it is used as the key to retrieve the name of the const.
But this is a manual solution, you'd have to register the name of each value in the hash at the start of your program.


RustyKristi(Posted 2016) [#3]
Thanks Kryzon. I did not notice there's a TMap equivalent for B3D. looks interesting