每次触发Jess规则时增加或更改变量

编程入门 行业动态 更新时间:2024-10-25 10:25:19
本文介绍了每次触发Jess规则时增加或更改变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

每次触发规则时,是否可以增加或更改某些变量的值? 我需要在每次规则触发时引入插槽的新值,因为在以下示例中,我将使用此值进行连接: 我有一个将三角洲转换为恒星的电路和规则.对于每个变换产品,都是一个附加节点.对于简单网络,我将其命名为T,但是对于更复杂的网络,我最终得到的是充满T节点的网络,因为每次触发另一个增量的规则时,我都会得到一个T节点.

Is there a way to increment or change value of some variable each time rule fires? I need that for every time rule fires introduce new value of the slot, since I will use this value for connectivity in the following example: I have an electric circuit and rule that transforms delta to star. For every transform product is additional node. For simple network I have named it T, but for more complicated network I end up with network that is full of T nodes, since every time rule is triggered for another delta, I get a T node.

推荐答案

Jess具有一种特殊的变量:全局变量.它们在程序的所有部分(包括规则的RHS)中都是可见的.要创建,请使用defglobal,例如

Jess has a special kind of variables: global variable. They are visible in all parts of a program, including the RHSs of the rules. To create, use defglobal, e.g.

(defglobal ?*firecount* = 0)

请注意,星号是必需的.

Note that the asterisks are mandatory.

您可以像使用其他任何变量一样使用它们:

You use them just like any other variable:

(++ ?*firecount*) (printout t "fire counter = " ?*firecount* crlf)

请注意,甚至reset都不会清除全局变量. -有关其他详细信息,请参阅Jess手册.

Note that not even reset clears a global. - Refer to the Jess manual for additional details.

更多推荐

每次触发Jess规则时增加或更改变量

本文发布于:2023-10-22 22:29:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1518918.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:变量   规则   Jess

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!