Copy link to clipboard
Copied
For a CFLoop, I want to set the condition so that the loop will run if there is any "step" in the text I am itterating over. I wrote:
<cfloop condition = FindNoCase("step",Code)>
.....
</cfloop>
I am getting an error that says:
Just in time compilation error
Invalid token found on line 45 at position 30. ColdFusion was looking at the following text:"
Whats wrong with what I have done?
sports_fan72 wrote:
<cfloop condition = "FindNoCase("/step",Result)">
ColdFusion is parsing that line like this: condition = "FindNoCase(" /step ",Result">
I.E. The first and second quotes are paired as are the third and forth. It has no idea what to do with whats in between the second and third.
You need to alternate your quotes when you need to nest them like that.
<cfloop condition = "FindNoCase('/step',Result)">
OR
<cfloop condition = 'FindNoCase("/step",Result)'>
Copy link to clipboard
Copied
The condition parameter of the cfloop tag is expecting a STRING of the command to be checked each loop.
In other words you need some quotes.
<cfloop condition = "FindNoCase('step',Code)">
With your version:
<cfloop condition = FindNoCase('step',Code)>
The loop was resolving the FindNoCase function, and expecting the result of that function to be the string that would be the 'Command' to use in each loop.
Copy link to clipboard
Copied
Its still not working. Not sure why. I write:
<cfloop condition = "FindNoCase("step",Code)">
and
<cfloop condition = FindNoCase('step',Code)>.
Neither works.
Copy link to clipboard
Copied
Since the expression is inside of double quote marks, you need to put hash marks around the function call so that CF knows to evaluate it, otherwise it is just looking at the literal string. Just like with CFDUMP's var argument.
Copy link to clipboard
Copied
I may be a bit off on that last statement, I just noticed that you don't really specify a condition in your string, just the function call itself. You need to tell CFLOOP what value of the findNoCase() call you want it to look for to exit the loop.
Copy link to clipboard
Copied
Reed Powell wrote:
Since the expression is inside of double quote marks, you need to put hash marks around the function
NO YOU DON'T. <cfloop condition...> is a bit of odd duck. You don't put a function or expression. You put a string that represents the function or expression you want evaluated each loop itteration. It is somewhat like an evaluate() string.
For example, from the docs.
http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Tags_j-l_12.html
<cfloop condition = "CountVar LESS THAN OR EQUAL TO 5">
You will note that the condition is in quotes, but there are NO hash|pound|number|othotrope|# characters used.
Copy link to clipboard
Copied
HOW is it not working? Errors, incorrect results, what are you seeing that we need to know to guide you.
Copy link to clipboard
Copied
This is my code:
<cfloop condition = "FindNoCase("/step",Result)">
The error I recieve says: "
Just in time compilation error
Invalid token found on line 38 at position 34.
ColdFusion was looking at the following text: /s Invalid expression element. The usual cause of this error is a misspelling in the expression text.
The last successfully parsed CFML construct was a CFLOOP tag occupying document position (38:1) to (38:7).
Copy link to clipboard
Copied
sports_fan72 wrote:
<cfloop condition = "FindNoCase("/step",Result)">
ColdFusion is parsing that line like this: condition = "FindNoCase(" /step ",Result">
I.E. The first and second quotes are paired as are the third and forth. It has no idea what to do with whats in between the second and third.
You need to alternate your quotes when you need to nest them like that.
<cfloop condition = "FindNoCase('/step',Result)">
OR
<cfloop condition = 'FindNoCase("/step",Result)'>
Copy link to clipboard
Copied
Oh, that makes sense. I thought the quotes would've been nested. Thanks