MACSCRPT Archives

May 2009

MACSCRPT@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Bill Steele <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Thu, 21 May 2009 11:16:15 -0400
Content-Type:
text/plain
Parts/Attachments:
text/plain (66 lines)
>
>On Thu, May 21, 2009 at 9:39 AM, Bill Steele <[log in to unmask]> wrote:
>>
>>  set recordList to {}
>>  set oneRecord to {foo:1, bar:"hello"}
>>  set end of recordList to oneRecord
>>  set twoRecord to {foo:2, bar:"Goodbye"}
>>  set end of recordList to twoRecord
>>  repeat with aRecord in recordList
>>  if foo of aRecord is 1
>>  set stuffIneeded to aRecord
>>  end if
>>  end repeat
>>  --> returns the entire list.
>
>Not OMM.  It does, however, return a reference to the first item of
>the list ("item 1") rather than the actual record.
>
>
>>  set stuffIneeded to CONTENTS of aRecord
>
>yup.
>
>>  Fairly easy to figure out (I managed), but not the way ordinary lists
>>  behave.
>
>No, it's exactly the way ordinary lists of *references* behave,
>whether the referenced items are records or application objects - or
>other lists.  This exhibits the same behavior.
>
>repeat with aList in { { 1, 2, 3 }, { 4, 5, 6 } }
>     if item 1 of aList is 1 then
>        set stuffIneeded to aList
>     end if
>end repeat
>stuffIneeded

This is getting interesting.  I've done a lot of stuff with hunting 
through ordinary lists and would have disagreed with you, but I 
experimented a bit:

set aList to {1, 2, 3}
repeat with oneNumber in aList
display dialog oneNumber --> works, 1, 2., 3
	if oneNumber is 2 then
		display dialog oneNumber --> zilch
	end if
end repeat

but

set aList to {1, 2, 3}
repeat with i from 1 to 3
	set oneNumber to item i of aList
	if oneNumber is 2 then
		display dialog oneNumber --> 2
	end if
end repeat

the "in list" syntax doesn't do comparisons, but "item of" does. 
Does that qualify as problematical?
-- 

Bill Steele
[log in to unmask]

ATOM RSS1 RSS2