Skip to main content

Equals (=)

Tests two operands for string equality.


The Equals operator tests two operands for string equality. When you apply Equals to two strings, ObjectScript returns a result of TRUE (1) if the two operands are identical strings with identical character sequences and no intervening characters, including spaces; otherwise it returns a result of FALSE (0). For example:


returns TRUE (1).


Equals does not imply any numeric interpretation of either operand. For example, the following statement produces a value of FALSE (0), even though the two operands are numerically identical:

 WRITE "007"="7"

You can use Equals to test for numeric equality if both operands have a numeric value. For example:

 WRITE 007=7

returns TRUE (1).

You can also force a numeric conversion by using the Unary Arithmetic Positive. For example:

 WRITE +"007"="7"

returns TRUE (1).

If the two operands are of different types, both operands are converted to strings and those strings are compared. Note that this may cause inaccuracy because of rounding and the number of significant digits for conversion to string. For example:

 WRITE "007"=7,!
  // converts 7 to "7", so FALSE (0)
 WRITE 007="7",!
  // converts 007 to "7", so TRUE (1)
 WRITE 17.1=$DOUBLE(17.1),!
  // converts both numbers to "17.1", so TRUE (1)
 WRITE 1.2345678901234567=$DOUBLE(1.2345678901234567),!
  // compares "1.2345678901234567" to "1.23456789012346", so FALSE (0)
FeedbackOpens in a new tab