Learn how to a build a cloud-first strategyRegister Now


Concatenate ColdFusion

Posted on 2006-04-25
Medium Priority
Last Modified: 2013-12-24
Hey guys.  This is very simple and I cannot figure it out.

Is this code possible?

<cfset cnt =  1>

<cfif isdefined('test#cnt#') and test#cnt# neq "">


I am trying to get the value of variable test1.
Question by:jramos74
  • 3

Expert Comment

ID: 16537965
Try evaluate("test#cnt#") to get the value held by a dynamically named variable.

Author Comment

ID: 16538063
Thanks incapital.

That is actually my previous code.  Here is tha actual code:

<cfif isdefined(evaluate("test#cnt#"))>

I am getting an error message.  I know something is wrong with my syntax.

Expert Comment

ID: 16538215
Right. Evaluate returns the value held by the dynamic variable, so it's not actually checking to see if the value exists.

You actually don't need to use evaluate in that case. Maybe the code below will help:

<cfset count = 1>
<cfset "test#count#" = 1>
The value of my dynamic variable is:<cfoutput>#evaluate("test#count#")#</cfoutput>

<cfif isDefined("test#count#")>
      I exist!

Accepted Solution

incapital earned 1000 total points
ID: 16538244
Also, remember that the second part of your if statement is actually checking for a value, so you'll have to use evaluate there...

<cfset count = 1>
<cfset "test#count#" = 1>

<cfif isDefined("test#count#") and evaluate("test#count#")>
      I exist!

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
Geo-targeting is the practice of distributing content based on a person’s location, as best as you can determine it. Let’s look at some ways you could successfully use this tactic. The following tips and case studies could lead to meaningful results.
The purpose of this video is to demonstrate how to insert an Iframe into WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Open Page or Post…
The purpose of this video is to demonstrate how to Test the speed of a WordPress Website. Site Speed is an important metric of a site’s health. Slow site speed can result in viewers leaving your site quickly and not seeing your content. This…
Suggested Courses
Course of the Month21 days, 6 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question