Skip to main content
Participating Frequently
September 6, 2006
Question

Dodging the evaluate function

  • September 6, 2006
  • 3 replies
  • 463 views
Hi,

I have a data source that supplies the scope, name and value of a variable. Obviously dynamic values is what CF is all about. A dynamic variable name can be used (without the evaluate function) by using:
#Form["product_" & i]#
But how do I use a dynamic scope, without using the evaluate function? I have used:
evaluate('#scope#'& '.' & '#variableName#')
and this seems to work. Does anyone know how to do this without using evaluate?

Thanks in advance.
Stephen
    This topic has been closed for replies.

    3 replies

    Inspiring
    September 6, 2006
    This is for a very particular application, that will be used for
    testing, so a
    lot of the concerns around evaluate are not so crucial. But thanks for the
    reminder regarding the variables scope acting as a structure. This will
    hopefully help others too.

    Stephen

    Just to add, the general consensus of those you know, there is not as
    much downside to evaluate() in the MX versions of ColdFusion. In CF
    previous to MX there was performance issues. But since MX,
    evaluate("form.#i#") and form parse to basically the same java
    bytecode. So the performance is very similar.
    zax_srbAuthor
    Participating Frequently
    September 6, 2006
    This is for a very particular application, that will be used for testing, so a lot of the concerns around evaluate are not so crucial. But thanks for the reminder regarding the variables scope acting as a structure. This will hopefully help others too.

    Stephen
    Inspiring
    September 6, 2006
    evaluate('#scope#'& '.' & '#variableName#')
    and this seems to work. Does anyone know how to do this without using
    evaluate?

    If even you scope is dynamic then evaluate is probably your only option.
    I just have never found a use for this much dynamic ability. With
    normal varialbes, most don't realize that they are in the variables
    scope and thus can be accessed as follows.

    #variables["variableName"]