ColdFusion 9 和 ColdFusion 7 之间关于 CFScript 的向后兼容性?

发布于 2024-11-25 03:05:42 字数 432 浏览 0 评论 0原文

我是一个完整的 ColdFusion 新手,所以为我即将到来的无知提前道歉。

我们的现有 CFScript 存在问题。有问题的脚本包含以下行:

...
if (fields.length() != 0) {
    // do something
}
...

该脚本在 ColdFusion 9 中运行成功,但在尝试在 ColdFusion 7 中运行该脚本时我们看到以下消息:

...
Invalid token '!' found on line...
...

我猜 ColdFusion 7 不喜欢 '!=' 运算符,我我说得对吗?

如果是这样,CFScript 是否还有其他向后兼容性问题可能导致我们出错?我一直在寻找资源,但似乎没有任何明确的信息。

谢谢。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

燃情 2024-12-02 03:05:42

是的,在 CF7 中,您需要使用 ColdFusion 的本机比较运算符,在您的情况下为 neq

==替换

  • eq
  • != 替换为 neq
  • > 替换为 gt
  • <lt
  • >=gte
  • <= 与 lte
  • %mod

就可以开始了。这些算子是向上兼容的,CF9会理解它们。

除此之外,

  • 您需要将所有局部变量(用 var 声明的变量)分组到 ColdFusion 7 中函数的顶部。此限制在后续版本中已消失ColdFusion,但以这种方式编写的脚本当然会继续运行。
  • 从 CF9 开始,有一个自动的 local 范围。此作用域在 CF7 和 CF8 中不可用,但按照惯例,人们在 CF7 函数顶部添加了 var local = StructNew();,这也适用于 CF > 。 7.

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,

  • you need to group all your local variables (those declared with 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.
  • there is an automatic 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.
_蜘蛛 2024-12-02 03:05:42

你是对的 - 类似 Javascript 的运算符(!=、==、|| 等)仅在 ColdFusion 9 中引入,同时还提供了更多的脚本支持。

这主要与 CFC 的完整脚本支持有关,但可能还有很多其他问题......

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...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文