I am a complete ColdFusion newbie so apologies in advance for my upcoming ignorance.
We are having an issue with an existing CFScript. The problematic script contains the following line:
...
if (fields.length() != 0) {
// do something
}
...
The script runs successfully in ColdFusion 9, but we see the following message when trying to run the script in ColdFusion 7:
...
Invalid token '!' found on line...
...
I'm guessing that ColdFusion 7 does not like the '!=' operator, am I correct?
If so, are there any other backward compatibility issues with CFScript that could cause us to trip up? I've been searching for resources but there doesn't seem to be anything definitive.
Thanks.
Yes, in CF7 you need to use ColdFusion's native comparison operators, in your case neq
.
Replace
==
with eq
!=
with neq
>
with gt
<
with lt
>=
with gte
<=
with lte
%
with mod
and you're good to go. These operators are upward-compatible, CF9 will understand them.
Other than that,
var
) at the top of a function in ColdFusion 7. This restriction has gone away in later editions of ColdFusion, but scripts written that way will of course continue to run.local
scope as of CF9. This scope was not available in CF7 and CF8, but by convention people added a var local = StructNew();
at the top of their CF7 functions, which will also work in CF > 7.You're right - the Javascript-like operators (!=, ==, ||, etc.) were only introduced in ColdFusion 9, along with a whole lot more scripting support.
This mostly relates to full script support for CFCs, but there are probably plenty of other other gotchas out there...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With