Compare.strings: Difference between revisions

From Sierra Wiki
Jump to navigationJump to search
Andrew Branscom (talk | contribs)
No edit summary
Andrew Branscom (talk | contribs)
 
(7 intermediate revisions by the same user not shown)
Line 3: Line 3:
[[AGI Logic Commands by Name|Return to AGI Logic Commands by Name]]
[[AGI Logic Commands by Name|Return to AGI Logic Commands by Name]]


<div align="center"><span style="font-size: 22pt">Compare.strings</div>
<div align="center"><span style="font-size: 22pt">compare.strings</div>


<br />
<br />
Line 59: Line 59:
|}
|}


== See Also ==
==<br /> References ==


[[Test Commands]]<br />
<references />
[[String Commands]]<br />
 
[[Category:Commands]]<br />
==<br /> Related Links ==
 
* [[AGI Command Reference - Test Commands|Test Commands]]
* [[AGI Command Reference - String Management Commands|String Commands]]
<br />&nbsp;
[[AGI Logic Commands by Name#Commands|< AGI Logic Command Index]]
&nbsp;
[[Category:Commands]]
[[Category:AGI Logic Commands]]

Latest revision as of 16:47, 4 April 2025

Return to AGI Logic Commands by Name

compare.strings



Introduction

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

Syntax

compare.strings(str sA, str sB)

Remarks

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.

Example

Code:
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)


References



Related Links


  < AGI Logic Command Index