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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Evaluate function in ColdFusion 6.1

Status
Not open for further replies.

NemaNada

Programmer
Jan 14, 2009
1
AU
Hi,

I'm a newbie that has inherited code that I need to maitain and I would appreciate some guidance.

I am having problems with the Evaluate function.

eg.

<cfif Evaluate(#table# & ".RecordCount") GT 0>

This has an Exception

Variable TableName.RecordCount is undefined


If I change to

<cfif Evaluate(table & "." & RecordCount) GT 0>

it works, the other code worked on version 6.0. Were there changes to the Evaluate function in 6.1 that is causing this or it a server configuration issue.

TIA
 
ColdFusion 6.1 is an old version. But you can always check the online documentation to find out what changed between versions


But first I would question why the code is using evaluate() at all. In later versions most "scopes" are available as a structure (ie #variables# scope, #form#, #url#, etcetera). So evaluate() is rarely needed. Personally, I do not use evaluate() because I think it is more reduces code readability and is more difficult to debug. But here is an example of both methods


But back to your original question. The two code snippets are doing two different things. In the second example, "RecordCount" is treated as a variable. So ultimately ColdFusion is evaluating two different statements:

Code 1:
evaluate(theValueOfTable &".RecordCount")

Code 2:
evaluate(theValueOfTable &"."& theValueOfRecordCount)

Which probably explains why one statement works and the other does not. Try revising the code to eliminate evaluate().





----------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top