Lemme clarify my usage a bit. I have a function that returns a specific property from a list and does some stuff to it (not important). The function call goes:
but since a “creation date” cannot be converted to the the actual property name creation date I’m up the creek. I need to turn “creation date” to the actual property name creation date.
set someObject to choose file
return GetProperty(someObject, "creation date")
on GetProperty(anObject, propertySought)
set propertyNames to ¬
{"class", "name", "index", "displayed name", "name extension", "extension hidden", "container", "disk", "position", "desktop position", "bounds", "kind", "label index", "locked", "description", "comment", "size", "physical size", "creation date", "modification date", "icon", "URL", "owner", "group", "owner privileges", "group privileges", "everyones privileges", "file type", "creator type", "stationery", "product version", "version"}
repeat with myIndex from 1 to count of propertyNames
if item myIndex of propertyNames = propertySought then exit repeat
end repeat
tell application "Finder"
return item myIndex of (get properties of anObject as list)
end tell
end GetProperty
I wonder if there is an implicit way to get the list propertyNames from the properties Property of an object.
(I copy/pasted and text-edited to create the explicit list, so I know that list of property names is somewhere inside the machine.)
set theFile to choose file
doSomething(theFile as text, "creation date")
on doSomething(theList, thePropertyToUse)
try
return run script "tell application \"Finder\" to get " & thePropertyToUse & " of item \"" & theList & "\""
on error
return missing value
end try
end doSomething