[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Translate String of Variable Name into Variable Value
- From: spam@...
- Date: Fri, 1 Jun 2007 07:02:49 -0700 (PDT)
I'm trying to expand some existing LUA code in a project. Below is a
simplified version of an existing function to explain what I'm after:
const foo = 4
function compare_value(a,b)
return a == b
end
I need to write an equivalent function that does the same as
"compare_value" when:
The value being passed to me for "a" the string name of one of several
pre-declared constants, like "foo" above.
The value being passed for "b" is an integer value out of the set of
possible constants above, in this case "4".
What I want to do is translate variable "a" from the string "foo" into its
equivalent named variable value of "4", so that:
compare_label("foo",4)
is true.
TIA for help. I'm missing something obvious, aren't I?