Skip to main content
Participating Frequently
February 12, 2009
Question

How to get value of variables which have dynamic name?

  • February 12, 2009
  • 3 replies
  • 1012 views
Hey guys,
1.For example, I have two variables:
<cfset varOne="One">
<cfset varArg="argument">
And I'd like to connect"argument" and "One" together as "argumentOne", then how can I get the value of "argumentOne"?

Thanks!
This topic has been closed for replies.

3 replies

Inspiring
February 12, 2009
What are you dumping? Your only argument is looking for a structure, so if you dump the arguments, you should see a structure somewhere. Do you? Does it include ruleFormData.minText_col1 ?

By the way, where are you trying to use it? I didn't see anything resembling that in your post of 02/12/2009 12:16:08 PM
safin_luoAuthor
Participating Frequently
February 13, 2009
yes, I've dumped the arguments and see a structure contains the form data, it includes ruleFormData.minText_col1
Now it works after I use #arguments[mintext & col_id]# instead of #variables[mintext & col_id]# as Azadi's suggestion.
Thank you!
Inspiring
February 12, 2009
Troubleshooting step number 1 - look at what you sent to your function.

<cffunction name="UpdateRule" returntype="void">
<cfargument name="ruleFormData" type="struct" required="true">
<cfdump var="#arguments#">
<cfabort>

Also, inside your function it's a good practice to use the keyword var when initializing local variables.

Finally at some point, it looks like qGetCol looks like it is also undefined.
safin_luoAuthor
Participating Frequently
February 12, 2009
I've used <cfdump> tag and it is sure that the Form data is passed to the function. Here are some of the dump information:
MAXTEXT_COL1 1100000000.00
MINTEXT_COL1 800000010.00

sorry that I forget to mention that qGetCol is defined in this function and I omitted it.
It is really strange that I can get the value of "#ruleFormData.maxtext_col1#" but can't get it by "#variables[minText & col_id]#"..
I don't know what caused this issue...
Inspiring
February 12, 2009
#variables[varArg & varOne]# works (preferred syntax)
#evaluate(varArg & varOne)# does as well (not so preferred)

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
safin_luoAuthor
Participating Frequently
February 12, 2009
Great, thank you so much!