It's not the best programming (see my suggestion following it), but the exact answer to your question is:
Code:
(setq second (eval(read first)))
Here's better programming (Use LISt Processing since this is LISP):
Code:
(setq vars (list (list "1" 12345)(list "2" 56789)(list "3" 10101)))
(initget 1 "1 2 3")(setq first (getkword "\nSpecify a variable [1/2/3]: "))
(setq second (cadr (assoc first vars)))
Let me know if that doesn't make sense or does not do what you need.
Tom
Originally Posted by
mattko
I'm having trouble with referring to a variable value by string. Searched a few hours, no luck.
Example:
(setq var1 12345)
(setq var2 56789)
(setq var3 10101)
Input a string and store it to a variable:
(setq first (getstring)) lets say "var2"
Set the value of the second variable based on the provided string.
(setq second (somethingsomething first))
>>> 56789