Just to wrap up and clarify here's a script that contains several examples
with key results commented out.
One thing I noticed in the exchange is that Bill believed he was getting the
entire list as a result of one of his commands, when he probably getting a
reference to an item in the list, but the reference contains the entire list
when displayed in the event log and SD's variable watcher.
------
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
recordList
repeat with aRecord in recordList
if foo of aRecord is 1 then
set stuffIneeded to aRecord
end if
end repeat
stuffIneeded
-->item 1 of {{foo:1, bar:"hello"}, {foo:2, bar:"Goodbye"}}
stuffIneeded as item
-->{foo:1, bar:"hello"}
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
--> item 1 of {{1, 2, 3}, {4, 5, 6}}
stuffIneeded as item
--> {1, 2, 3}
set aList to {1, 2, 3}
repeat with oneNumber in aList
display dialog oneNumber --> works, 1, 2., 3
oneNumber
-->item 1 of {1, 2, 3}
--if oneNumber = 2 then
if oneNumber as item = 2 then
display dialog oneNumber --> bingo!
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
oneNumber
-->1
if oneNumber is 2 then
display dialog oneNumber --> 2
end if
end repeat
repeat with aRecord in recordList
aRecord
-->item 1 of {{foo:1, bar:"hello"}, {foo:2, bar:"Goodbye"}}
if foo of aRecord is 1 then
set stuffIneeded to aRecord
stuffIneeded
-->>item 1 of {{foo:1, bar:"hello"}, {foo:2, bar:"Goodbye"}}
stuffIneeded as item
-->>{foo:1, bar:"hello"}
end if
end repeat
--> returns the entire list.
--I don't think so, it may look like the entire list but it is actually the
reference form:
-- item x of [entirelist]
-->Bill> set stuffIneeded to CONTENTS of aRecord
-->Me> I prefer aRecord as item
------------
HTH,
ES
|