To determine whether an item or value exists:
item-or-value {exists | does not exist}
-> truth-value
For an item, use this expression to determine whether the item exists and is active. For example:
wait until proof-checker-1 exists checking every 5 seconds
if the public-name of the temperature T of my-tank exists
then ...
has a value and has a current value expressions. See Variable and Parameter Expressions.
There Exists
To determine whether an item or value exists:
there exists {a | an} generic-reference-expression
such that (truth-value-expression)
-> truth-value
If the specified generic reference expression refers to items, this expression produces either truth-value
true or false, or a no value condition, as follows:
true if the current KB contains at least one item that meets the specified criterion. The expiration time of this expression is the minimum expiration time of either the generic reference expression or the first instance of the embedded truth-value expression that produces the truth-value true.
false if no items in the current KB meet the specified criterion. The expiration time of this expression is the minimum expiration time of either the generic reference expression or the minimum expiration time among those of the instances of the embedded truth-value expression.
true, you can refer to the generic reference expression's local name in other expressions within this expression's transaction scope. In this case, the local name refers to a value when the such that phrase evaluated to the truth-value true. If there is no such that phrase, the local name refers to the first instance of the generic reference expression. For example, this rule's antecedent contains a there exists expression:
if there exists a vat V1 such that ( V1 is overflowing ) then ...
V1 is overflowing produces the truth-value true if at least one vat is overflowing, but produces the truth-value false if no vat is overflowing. If the
there exists expression produces the truth-value false, the value that the local name refers to is not predictable. In the sample rule shown above, if the there exists a vat V1 ... expression produces the truth-value false, then references to the V1 local name in this rule's consequent might produce a different truth-value.
there exists expression if it references indexed attributes. See Defining an Indexed Attribute for more information about indexed attributes.
Class or Type of Item or Value
To determine the class of an item or type of value:
item-or-value is {a | an} {class-name | type}
- truth-value
if the item I nearest to help-button is a custom-object then
conclude that the status of I is ok
To reference items or values generically:
for every generic-reference-expression (truth-value-expression)->truth-value
true or false, or produces a no value condition, as follows:
true if the specified truth-value expression produces the truth-value true for every item or value in the specified generic reference expression. If so, the expiration time of the expression is the minimum of the expiration times of the items or values produced by the generic reference expression and of all instances of the embedded truth-value expression.
false if the specified truth-value expression produces the truth-value false for any item or value produced by the specified generic reference expression. The expiration time of this expression is the expiration time of the first instance of the specified truth-value expression that produces the truth-value false.
false for every item or value produced by the specified generic reference expression. In this case, the expiration time of the expression produces the no value condition.
For example:
for every valve V connected to tank-1 ( V is broken )
true if every valve connected to tank-1 is broken. Otherwise, it produces the truth-value false. Note that if no items or values match the generic reference expression, the expression produces the truth-value true.
To perform conditional evaluation:
(if truth-value-expression then item-or-value [else item-or-value] )->{item | integer | float | symbol | text | truth-value}
If there is no
else phrase, and the truth-value expression produces the truth-value false, then the entire expression produces a no value condition. The expiration time of this expression is the minimum of the expiration times of the specified truth-value expression and of G2's evaluation of either the
then phrase or the else phrase. You can nest this expression within other expressions, even with other conditional expressions. Some examples are:
the area of tank-1 *
(if the current time < 2 then 10 else the level of tank-1)
the status-light of tank-1 =
(if the level of tank-1 > 100 then the symbol red else the symbol green)
if (if valve-1 is open then 10 else 0) > the outflow of tank-1 then
conclude that tank-1 is filling
(if tank-1 is empty then
(if valve-1 is closed then the symbol green else the symbol red)
else the symbol green)
To determine the value or an item or value:
the value of item-or-value->{item | integer | float | symbol | text | truth-value}
The expiration time of the entire expression is the expiration time of the value produced by the specified expression. For example:
the value of (if the custom-variable CV that is synchronized-with the
temperature-variable giving the temperature of tank-1 is not broken then
CV else the temperature of tank-1)
Temperature attribute of tank-1. If either that custom-variable or the temperature-value variable that gives the Temperature attribute of tank-1 does not have a current value, then G2 performs data seeking to obtain a value.
To determine whether an item or value has a value:
item-or-value has {a | no} value
-> truth-value
the temperature of the most-reliable-measures of tank-1 has a value
the temperature of the most-reliable-measures of tank-1 refers to any variables or parameters, and if those variables or parameters each have a valid current value, then this expression produces the truth-value true. If those referenced variables or parameters have never received a value, or if any of their respective current values have expired, then this expression causes G2 to perform data seeking to obtain new current values. If G2 obtains a value from that data seeking, then the entire expression produces the truth-value true, else the entire expression produces the truth-value false.
To determine the first item or value with a value:
the first of the following expressions that has a value
(item-or-value [, item-or-value ...] )->{item | integer | float | symbol | text | truth-value}
G2 attempts to evaluate each item-or-value expression in the specified list, going from left to right. If the expression being evaluated refers to a variable or parameter that has never received a value or that has an expired current value, then G2 performs data seeking for those variables or parameters. If G2 cannot obtain a value for any of the specified item-or-value expressions, the entire expression produces the truth-value
false. For example:
the first of the following expressions that has a value
(the temperature of tank-1,
average-system-temperature,
(if the current time >= 10 then 50 else 55))
the temperature of tank-1 has a value, G2 produces that value as the value of the entire expression. If not, G2 performs data seeking, as needed, to obtain a new current value for any variables referenced in the the temperature of tank-1 expression.
the temperature of tank-1 expression, G2 next checks average-system-temperature for a valid value. If it has a valid value, G2 produces that value as the value of the entire expression. If average-system-temperature does not have a valid value, and if it is a variable, then G2 performs data seeking to obtain a new current value.
average-system-temperature, the value of the entire expression is either 50 or 55, depending on the G2 clock's current time, as specified in the expression (if the current time >= 10 then 50 else 55).
For the majority of expressions, the expiration time is the minimum of the expiration time of the values of the expression's terms. As an example, if the expiration time of
X is 50, and the expiration of Y is 10, the expiration time of the expression X + Y is 10.
To determine the current value of an item or value:
the current value of item-or-value->{item | integer | float | symbol | text | truth-value}
if the current value of the temperature of tank-1 exists
then ...
Temperature attribute of tank-1 has a current value. If the temperature of tank-1 does not have a value, is no longer current, or refers to an item that does not exist, then this expression produces a no value condition.
To determine whether an item or value has a current value:
item-or-value has {a | no} current value
-> truth-value
If this expression produces the truth-value
true, its expiration time is the expiration time of the value that the specified item-or-value expression produces. If this expression produces the truth-value false, the expiration time is indefinite. If a
has a value expression is nested within a has a current value expression, G2 evaluates the nested expression no differently than a has a value expression. That is, G2 performs data seeking, if necessary, to obtain a new current value for any variables referenced in the nested expression. For example:
if the temperature of the most-reliable-measures of tank-1 has a current value
then ...
the temperature of the most-reliable-measures of tank-1 without the need to obtain a new current value for any variables referenced in that expression, then this expression produces the truth-value true. Otherwise, this expression produces the truth-value false.
To determine the first item or value with a current value:
the first of the following expressions that has a current value
(item-or-value [, item-or-value ... ] )->{item | integer | float | symbol | text | truth-value}
G2 attempts to evaluate each expression in the specified list, going from left to right. If none of the specified expressions has a value, or if none have a current value, then this expression produces a no value condition and no error is signalled. For example:
the first of the following expressions that has a current value
(the temperature of tank-1,
average-system-temperature,
(if the current time >= 10 then 55 else 50))
the temperature of tank-1 has a current value, G2 produces that value as the value of the entire expression.
the temperature of tank-1 does not have a current value, G2 next checks average-system-temperature for a current value. If it has a current value, G2 produces that value as the value of the entire expression.
average-system-temperature does not have a current value, the value of the entire expression is either 50 or 55, depending on the G2 clock's current time, as specified in the expression (if the current time >= 10 then 55 else 50).
To determine the count of:
the count of each generic-reference-expression
[such that (truth-value-expression)]->integer
For example, the following expression finds the number of objects upon this executable item's workspace whose
Number-of-edits attribute is greater than four:
the count of each object O upon my-object-ws such that
( the number-of-edits of O > 4 )
the count of expression if it references indexed attributes. See Defining an Indexed Attribute for more information about indexed attributes.
The Average Over Each
To determine the average over each:
the average over each generic-reference-expression of (quantity-expression)->float
float from values in the set of items or values in the specified generic reference expression. For example:
the average over each valve V connected to tank-1 of ( the flow of V )
To perform operations over a set:
the {sum | product | minimum | maximum}
over each generic-reference-expression of (quantity-expression)
-> {integer | float}
quantity from values in the set of quantitative variables, quantitative parameters, or numeric values in the specified generic reference expression. For example, the following expression computes the minimum of the flows of all valves that are connected to
tank-1:
the minimum over each valve V connected to tank-1 of ( the flow of V )