[Cook] Comparing two strings for equality
Jerry Pendergraft
jerry at endocardial.com
Thu Jun 19 07:20:10 EST 2003
If string1 and string2 are simple strings the "in" would work but
the more normal operator would be
if [ matches [string1] [string2]] then ...
If string2 was a word list then the "in" would show if string1 matches any
of string2's content.
If string1 is a word list then you get completely different semantics:
Say string1 = a b c;
and string2 = d e f;
[in [string1] [string2] ]
is equivalent to:
[in a b c d e f]
It is not
[in a b c d e f]
Checking for membership of a set like that can be done a couple ways
using [stringset]. Check the user guide for examples.
hope that helps
On Wed, 18 Jun 2003, Jody Hagins wrote:
>
>
> I am a bit confused by how I should compare two strings for equality.
> It seems that I should be using something like...
>
>
> if [in [string1] [string2]] then
> {
> /* The two strings are equivalent */
> }
>
>
> but I am a bit bothered by the implicit meaning of "in" especially of
> [string2] happens to expand to a word list. What am I missing? I am
> simply looking for something that will tell me if two variables are
> identical (they both may be wordlists, or may be strings or whatever --
> I just want to compare them to see if they are the same).
>
>
> Thanks!
>
--
Jerry Pendergraft jerry.pendergraft at endocardial.com
Endocardial Solutions voice: 651-523-6935
1350 Energy Lane, Suite 110 fax: 651-644-7897
St Paul, MN 55108-5254 mobile: 651-491-0163
More information about the Cook-users
mailing list