- With the defglobal construct, global variables can be defined, set and accessed within the CLIPS environment.
- Global variables can be accessed as part of the pattern-matching process, but changing them does not invoke the pattern matching process.
- The bind function is used to set the value of global variables.
- Global variables are reset to their original value when the reset command is performed or when bind is called for the global with no values.
- Global variables can be removed by using the clear command or the underfglobal command.
- Syntax
<global-assignment> ::= <global-variables> = <expression>
<global-variable> : := ?* <symbol>*
- There may be multiple defglobal constructs and any number of global variables may be defined in each defglobal statement.
- The optional <defmodule -name> indicates the module in which the defglobal will be defined. If none is specified, the globals will be placed in the current module.
- Global variables may be used anyplace that a local variable could be used (with two exceptions).
- Global variables may not be used as a parameter variable for a deffunction, defmethod, or message-handler.
- Global variables may not be used in the same way that a local variables is used on the LHS of a rule to bind a value.
- Therefore, the following rule is illegal
( fact ?*x*)
- Note that this rule will not necessarily be updated when the value of ?*x* is changed. For example, if ?*x* is 4 and the fact (fact 3) is added, then the rule is not satisfied. If the value of ?*x* is now changed to 2, the rule will not be activated.
No comments:
Post a Comment