Reference a variable within a variable in JMeter

Check this forum: from Blazemeter

For example: getting value of varible "listid_XXX" where the XXX number comes from an index variable:

${__V(listid_${idx1})}

To solve this you should use hostname = ${__eval(${localhost})}
http://jmeter.apache.org/usermanual/functions.html#__eval
Carlos' answer has a mistake (which I can't comment on due to rep) as it uses evalVar, this requires as an argument a plain string:

This works: ${__evalVar(localhost)})
This works: ${__eval(${localhost})}
This doesn't work (the current answer): ${__evalVar(${localhost})} http://jmeter.apache.org/usermanual/functions.html#__evalVar


I've managed to solve my problem. I've changed the hostname variable value to: ${__evalVar(${localhost})}, but I've got this error:

ERRROR jmeter.functions.EvalVarFunction: Variables have not yet been defined

So I've moved the hostname variable declaration in a "User defined variable" child node of my Sampler node. That solved it.