Solved

coldfusion syntax error

Posted on 2013-02-01
4
253 Views
Last Modified: 2013-02-04
Hi experts,

I have a syntax error in these code but I can't see where.

The error shown is :
Invalid CFML construct found on line 341 at column 23.
ColdFusion was looking at the following text:
;

		<!--- get form's data & store into pages (cfc's) --->
		<cfloop list="#variables.languages#" index="variables.lang">
			<!--- get & store default language's data --->
			<cfif variables.lang EQ application.languageByDefault>
				<!--- title --->
				<cfset variables["cfc_" & variables.lang].setTitle(evaluate('form.title_#application.languages["#variables.lang#"]#'))>
				<cfset variables.defaultTitle = evaluate('form.title_#application.languages["#variables.lang#"]#')>
				<!--- description --->
				<cfset variables["cfc_" & variables.lang].setDescription(evaluate('form.description_#application.languages["#variables.lang#"]#'))>
				<cfset variables.defaultDescription = evaluate('form.title_#application.languages["#variables.lang#"]#')>
				<!--- keywords --->
				<cfset variables["cfc_" & variables.lang].setKeywords(evaluate('form.keywords_#application.languages["#variables.lang#"]#'))>
				<cfset variables.defaultKeywords = evaluate('form.title_#application.languages["#variables.lang#"]#')>
				<!--- page's body --->
				<cfset variables["cfc_" & variables.lang].setBody(evaluate('form.body_#application.languages["#variables.lang#"]#'))>
				<cfset variables.defaultBody = evaluate('form.title_#application.languages["#variables.lang#"]#')>
				<!--- save data to the database --->
				<cfset entitySave(evaluate('variables.cfc_#variables.lang#'))>
				<cfset ormFlush()>
				<cfbreak>
			</cfif>
		</cfloop>

Open in new window



the line 341 is the line below
<!--- title --->
:
		<cfloop list="#variables.languages#" index="variables.lang">
			<!--- get & store other language's data --->
			<cfif variables.lang NEQ application.languageByDefault>
				<!--- title --->
				<cfset variables.valueToTest = evaluate('form.title_#application.languages["#variables.lang#"]#')>
				<cfif variables.valueToTest NEQ "">
					<cfset variables["cfc_" & variables.lang].setTitle(evaluate('form.title_#application.languages["#variables.lang#"]#'))>
				<cfelse> <!--- this language's value is empty : store default language's value --->
					<cfset variables["cfc_" & variables.lang].setTitle(variables.defaultTitle)>
				</cfif>
				<!--- description --->
				<cfset variables.valueToTest = evaluate('form.description_#application.languages["#variables.lang#"]#')>
				<cfif variables.valueToTest NEQ "">
					<cfset variables["cfc_" & variables.lang].setDescription(evaluate('form.description_#application.languages["#variables.lang#"]#'))>
				<cfelse> <!--- this language's value is empty : store default language's value --->
					<cfset variables["cfc_" & variables.lang].setDescription(variables.defaultDescription)>
				</cfif>
				<!--- keywords --->
				<cfset variables.valueToTest = evaluate('form.keywords_#application.languages["#variables.lang#"]#')>
				<cfif variables.valueToTest NEQ "">
					<cfset variables["cfc_" & variables.lang].setKeywords(evaluate('form.keywords_#application.languages["#variables.lang#"]#'))>
				<cfelse> <!--- this language's value is empty : store default language's value --->
					<cfset variables["cfc_" & variables.lang].setKeywords(variables.defaultKeywords)>
				</cfif>
				<!--- page's body --->
				<cfset variables.valueToTest = evaluate('form.body_#application.languages["#variables.lang#"]#')>
				<cfif variables.valueToTest NEQ "">
					<cfset variables["cfc_" & variables.lang].setBody(evaluate('form.body_#application.languages["#variables.lang#"]#'))>
				<cfelse> <!--- this language's value is empty : store default language's value --->
					<cfset variables["cfc_" & variables.lang].setBody(variables.defaultBody)>
				</cfif>
				<!--- save data to the database --->
				<cfset entitySave(evaluate('variables.cfc_#variables.lang#'))>
				<cfset ormFlush()>
			</cfif>
		</cfloop>

Open in new window


Do you have an idea ?
0
Comment
Question by:adam1h
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 52

Expert Comment

by:_agx_
ID: 38844384
Don't trust error messages 100%.  Sometimes the error line # is way past the actual problem. It's just where the compiler gave up.

I don't see any semi-colons ";" in that code.  Are there any semi-colon's in the sections leading up to that line?

Complete shot in the dark, but sometimes I get that error when converting cfscript to cfml and forget to change the closing mark from ";" to ">", causing that error  ie

                  <cfset b = 123;              <=== invalid
                  <cfset b = 123>             <=== valid
0
 
LVL 39

Accepted Solution

by:
gdemaria earned 500 total points
ID: 38844389
It's curious that you seem very comfortable using the structure format but then also throw in unnecessary "evaluate()" functions with extra quotes.

I suggest rewriting for clearify and simplicy

These lines ...
<cfset variables["cfc_" & variables.lang].setTitle(evaluate('form.title_#application.languages["#variables.lang#"]#'))>
<cfset variables.defaultTitle = evaluate('form.title_#application.languages["#variables.lang#"]#')>

Open in new window


Can be rewritten as follows..
<cfset variables.defaultTitle = form.["title_" & application.languages[variables.lang]]>
<cfset variables["cfc_" & variables.lang].setTitle(variables.defaultTitle)>

Open in new window



Note that the second version uses the "defaultTitle" variable that you created so you don't have to derrive the same value twice.
0
 

Author Comment

by:adam1h
ID: 38844413
Hi both,

No I haven't any ; in my code.

Us I will try to rewrite & simplify

We'll see
0
 
LVL 52

Expert Comment

by:_agx_
ID: 38844442
Yeah, I'd agree you should refactor. I'd rollback the "bad" changes and start with a last know "good" copy. Go from there.
0

Featured Post

Is Your DevOps Pipeline Leaking?

Is your CI/CD pipeline a hodge-podge of randomly connected tools? You’ve likely got a tool to fix one problem & then a different tool to fix another, resulting in a cluster of tools with overlapping functionality. Learn how to optimize your pipeline with Gartner's recommendations

Question has a verified solution.

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

PROBLEM:  How to open a cfwindow or run a function on double click of a cfgrid row. One of my clients wanted to be able to double click on a row item to get more detailed information about a transaction and to be able to modify the line items i…
Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

729 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