Re: Question about repeat loop
Re: Question about repeat loop
- Subject: Re: Question about repeat loop
- From: Bill Briggs <email@hidden>
- Date: Sat, 14 Jul 2001 14:25:44 -0300
Sure. And if you put the list below in as the last line of your
script and run it you'll see why.
{TheItem1, TheItem2, TheItem1 as text, TheItem2 as text}
You'll get this.
--> {item 5 of {"I", "want", "this", "to", "work"}, item 2 of
{"please", "work"}, "work", "work"}
In the first case you are evaluating the equality of two references,
which are of necessity different because they refer to items in
different lists. In the second you are evaluating the equality of the
two items to which the references refer. When coerced to their actual
values, they are equal, as you'd expect.
If you put that list inside the first repeat loop and you can step
through the code (requires something other than Script Editor), you'd
note that the references take on a slightly different form, but the
upshot is essentially the same.
{item 1 of list1 of +script;, item 1 of list2 of +script;, "I", "please"}
- web
At 9:47 AM -0700 14/07/01, Phil Calvert wrote:
Can someone tell me why the "if ((TheItem1) is (TheItem2))" is never true in
this bit of code but "if ((TheItem1 as text) is (TheItem2 as text))" is
true?
--
set list1 to {"I", "want", "this", "to", "work"}
set list2 to {"please", "work"}
repeat with TheItem1 in list1
repeat with TheItem2 in list2
if ((TheItem1) is (TheItem2)) then--this is never true
display dialog "I'm in the if 1"
exit repeat
end if
end repeat
end repeat
repeat with TheItem1 in list1
repeat with TheItem2 in list2
if ((TheItem1 as text) is (TheItem2 as text)) then--this works
display dialog "I'm in the if 2"
exit repeat
end if
end repeat
end repeat