PDA

View Full Version : Comparing Two Strings



Desmond
10-03-2003, 02:23 PM
<HTML> <HEAD> <TITLE>AutoPlay Media Studio 5.0 Knowledge Base</TITLE> </HEAD> <BODY> <h3>Comparing Two Strings</h3> <b>Document ID: IR10085</b> <hr> The information in this article applies to: <ul> <li>AutoPlay Media Studio 5.0 Standard Edition</li> <li>AutoPlay Media Studio 5.0 Professional Edition</li> </ul> <hr> <h3>SUMMARY</h3> <p>This article describes how to compare two strings.</p> <h3>DISCUSSION</h3> <p> String comparisons are performed in the same manor as number comparisons. As an example, we will create two strings, and perform an action based on their contents: </p> <ol> <li>Create two variables containing strings:<pre><code>String1 = "I am String1";
<br />String2 = "I am String2";</code></pre> </li> <li>Compare the two strings:<pre><code>if String1 == String2 then
<br /> --the two strings are equal
<br />else
<br /> --the two strings are not equal
<br /> if String1 > String2 then
<br /> --String1 is alphabetically larger than String2
<br /> elseif String1 < String2 then
<br /> --String1 is alphabetically smaller than String2
<br /> end
<br />end</code></pre> </li> </ol> <p>Please note that if you want to compare the lengths of two strings, you must use the String.Length action:<br> <br><code> if String.Length(String1) == String.Length(String2) then<br> --the two strings are the same length!!<br> end<br></code> </p> <h3>MORE INFORMATION</h3> <p>For more information please see the following topics in the AutoPlay Media Studio 5.0 help file:</p> <ul> <li><b>Program Reference | Actions | String | String.Length</b></li> </ul> <p>KEYWORDS: AutoPlay Media Studio 5.0, String, Length, Compare </p> <hr> <FONT SIZE=1> Last reviewed: October 3, 2003<br> Copyright 2003 <A HREF="http://www.indigorose.com" target="blank">Indigo Rose Corporation</a>. All rights reserved.<br> </FONT> </BODY> </HTML>