From AGI Wiki
Revision as of 11:51, 14 April 2019 by Andrew Korson (Talk | contribs) (Example)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

The compare.strings test command compares two strings. It returns TRUE if the strings are the same.


compare.strings(str sA, str sB)


Test commands are only valid in an if statement.

This statement can be combined with the NOT operator to create a 'strings not equal' test.

The comparison is not case-sensitive, and the following characters are ignored:

  • space
  • tab
  • period
  • comma
  • semicolon
  • colon
  • single-quote
  • exclamation point
  • dash

If you are not aware of this, you may struggle in trying to understand why your code is not working as expected.

Possible Errors

AGI does not check that a valid string argument is passed. If an invalid string number is used (the limit is 24 [s0 - s23], except for versions 2.089, 2.272 and 3.002.149, which have a limit of 12 [s0 - s11]) AGI will read data from memory used for other purposes, and the returned value will be meaningless.


set.string(s1, "Some Text");
set.string(s2, "   some:TEXT!");
if(compare.strings(s1, s2))
  print("SURPRISE! these two strings are the same!");

Technical Information

Required Interpreter Version: Available in all AGI versions.
Byte-Code Value: 15 (0x0F hex)

See Also

Test Commands
String Commands