Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Evaluate 1

Status
Not open for further replies.

iao

Programmer
Feb 23, 2001
111
US
Does anyone know what I am doing wrong?

I am trying to use the Evaluate function. I have created a query and am trying to only ouput part of a string value (the initial 5 characters are removed).

I set the value TR1 to the value of the string.
I then set a value TR2 to the length of the string.
Lastly, I set TR3 to be the length of the string minus 5.

<cfset TR1 = #qInfo.ADR#>
<CFSET TR2 = #len(TR1)#>14
<CFSET TR3 = (#len(TR2)# - 5)>9

Then, I want to output this value. Since there is more than one local variable used in this statement, I use the Evaluate function.

<CFOUTPUT>
#Evaluate(right(TR1, TR3)#
</CFOUTPUT>

This doesn't work. Anyone know what I am doing wrong? The error is:

Invalid parser construct found on line 1 at position 3. ColdFusion was looking at the following text:
 
The problem with the above method is:
<CFSET TR3 = (#len(TR2)# - 5)>9

The value of TR2 is 14, so #Len(TR2)# = 2. Change this line to

<CFSET TR3 = (#len(TR1)# - 5)>9

And there's no need for Evaluate()

<CFSET TR1 = #qInfo.ADR#>
<CFSET TR2 = #len(TR1)#>14
<CFSET TR3 = (#len(TR1)# - 5)>9

<CFOUTPUT>
#right(TR1, TR3)#
</CFOUTPUT>

And simpler way to do all this would simply be:

<CFOUTPUT>
#right(qInfo.ADR, Len(qInfo.ADR) - 5)#
</CFOUTPUT> - tleish
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top