Compare.strings: Difference between revisions
sierraw>Andrew Branscom m 2 revisions imported |
|||
(15 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
The '''compare.strings''' test command compares two [[ | [[Category:AGI Pages]] | ||
[[Category:AGI Pages to be Edited]] | |||
[[AGI Logic Commands by Name|Return to AGI Logic Commands by Name]] | |||
<div align="center"><span style="font-size: 22pt">compare.strings</div> | |||
<br /> | |||
==<br /> Introduction == | |||
The '''compare.strings''' test command compares two [[String (AGI)|strings]]. It returns TRUE if the strings are the same. | |||
== Syntax == | == Syntax == | ||
compare.strings([[ | compare.strings([[String (AGI)|str]] sA, [[String (AGI)|str]] sB) | ||
== Remarks == | == Remarks == | ||
Line 25: | Line 35: | ||
== Possible Errors == | == 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. | AGI does not check that a valid [[String (AGI)|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 == | == Example == | ||
Line 49: | Line 59: | ||
|} | |} | ||
== | ==<br /> References == | ||
<references /> | |||
==<br /> Related Links == | |||
[[Test Commands]] | * [[AGI Command Reference - Test Commands|Test Commands]] | ||
[[String Commands]]<br /> | * [[AGI Command Reference - String Management Commands|String Commands]] | ||
[[Category:Commands]] | <br /> | ||
[[AGI Logic Commands by Name#Commands|< AGI Logic Command Index]] | |||
| |||
[[Category:Commands]] | |||
[[Category:AGI Logic Commands]] |
Latest revision as of 17:47, 4 April 2025
Return to AGI Logic Commands by Name
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
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