using variables in place of property labels
using variables in place of property labels
- Subject: using variables in place of property labels
- From: "Wallace, William" <email@hidden>
- Date: Fri, 5 Dec 2003 12:11:25 -0600
- Thread-topic: using variables in place of property labels
Say for instance I have a record:
set myRecord to {name:"Robert", age:32, shoe_size:13}
Is there no way to do this:
set myLabel to "name"
get myLabel of myRecord
-->bob
or more specifically:
set myRecord to {name:"Robert", age:32, shoe_size:13}
set myLabels to {"name","age","shoe_size"}
repeat with i from 1 to count of myLabels
set myProperty to item i of myLabels
get myProperty of myRecord
end repeat
I have in my script, a large record. Actually two records. One is a record of the initial state of an object the other is a record of the subsequently modified state of the same object. I'd like to compare some (but not all) of the properties of the new state to the old state and change them back to their initial settings. There are enough of these properties to be checked that I thought it would be convenient to loop through the process in manner similar to the above, but it don't work. Does anybody know of a way to achieve this without having to hardwire a bunch of if-then statements for each individual property to be examined?
what I really want to do is something like this:
set myOldRecord to {name:"Bobby", age:11, shoe_size:7, height:"4 feet 9 inches", weight:"105lbs."}
set myNewRecord to {name:"Robert", age:32, shoe_size:13, height:"6 feet 3 inches", weight:"216lbs."}
set myLabels to {"name","shoe_size","weight"}
repeat with i from 1 to count of myLabels
set myProperty to item i of myLabels
if myProperty of myNewRecord is not myProperty of myOldRecord
set myProperty of myNewRecord to myProperty of myOldRecord
end if
end repeat
--{name:"Bobby", age:32, shoe_size:7, height:"6 feet 3 inches", weight:"105lbs."}
(I know... Bobby's a weird looking dude)
B!ll
PS - Thanks for all your help with that other stuff, Hans.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.