Compare.strings: Difference between revisions
No edit summary |
No edit summary |
||
| Line 59: | Line 59: | ||
|} | |} | ||
== | ==<br /> References == | ||
[[Test Commands]] | <references /> | ||
[[String Commands]] | |||
[[Category:Commands]] | ==<br /> Related Links == | ||
* [[Test Commands]] | |||
* [[String Commands]] | |||
| |||
[[Category:Commands]] | |||
[[Category:AGI Logic Commands]] | |||
Revision as of 17:08, 3 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
Related Links