operator
=
, the result is true if the expressions are equal, and false if they are not. The
results are reversed for !=
.expression = expression expression (!)?= expression
You can determine whether one expression equals another with the =
operator. You can determine
whether one expression differs from another with the !=
operator. Either operator can be used with
any data type expression. You can compare values of mixed data types (for example, BCD numbers and integers) as
long as both types are available and you follow the rules listed in Operations with mixed data types.
For example, the following program compares two string
values
process local string left initial { "Catch-up" } local string right initial { "Catch-22" } do when left != right output left || " != " || right || "%n" else when left = right output "String compare has an error." || "%n" done ; Output: "Catch-Up != Catch-22"
The following program compares two expressions of differing types:
import "ombcd.xmd" unprefixed process local bcd left initial { 33 } local integer right initial { 33 } do when left = right output "Correct. BCD of " || "d" % left || " shown as equal to integer of " || "d" % right || ".%n" else output "Error. BCD of " || "d" % left || " shown as not equal to integer of " || "d" % right || ".%n" done ; Output: "Correct. BCD of 33 shown as equal to integer of 33."
is equal
is a deprecated synonym for =
, and isnt equal
is a deprecated
synonym for !=
.