Probably a newbie question.
I have a series of constant values (as string) in a popupmenu. These constants are related to integer value.
How I can get back the integer value from the string which is returned by the PopupMenu.text?
The way I’ve founded, works but is not elegant.
dim temp as string
dim ColorS as integer
temp=PopupMenu1.text
select case temp
case "CV_HSV2RGB"
ColorS= CV_HSV2RGB
case "CV_HSV2BGR"
ColorS= CV_HSV2BGR
case "CV_BGR2HLS"
ColorS= CV_BGR2HLS
case "CV_RGB2HLS"
ColorS= CV_RGB2HLS
case "CV_HLS2BGR"
ColorS= CV_HLS2BGR
case "CV_HLS2RGB"
ColorS= CV_HLS2RGB
case "CV_BGR2Lab"
ColorS= CV_BGR2Lab
case "CV_RGB2Lab"
ColorS= CV_RGB2Lab
case "CV_Lab2BGR"
ColorS= CV_Lab2BGR
case "CV_Lab2RGB"
ColorS= CV_Lab2RGB
case "CV_BGR2Luv"
ColorS= CV_BGR2Luv
case "CV_RGB2Luv"
ColorS= CV_RGB2Luv
case "CV_Luv2BGR"
ColorS= CV_Luv2BGR
case "CV_Luv2RGB"
ColorS= CV_Luv2RGB
end Select
In other language such as Rebol or Red some instruction similar to colorS: get to word! face/text, gives a direct access to the value of the constant.
BTW, in the popupmenu we can use #constant name but after compilation the name of the constant is replaced by the value (e.g. CV_HSV2RGB is replaced by 54) , which is correct but not convenient for user!
Thanks a lot.