Getting only the writable properties of a class

Is there a standard AppleScript construct to get only those properties of a class that are settable?

I ask because I’m writing a scriptable app, and I want to make it possible to use “make new … with properties X”, where X are properties fetched from another object of the same class. I do not want to use duplicate for this (because I do not want all the elements duped), so I am looking for a convenient way to copy just the top properties from an existing object to the new one.

Ideally, one should be able to write something like this:

set oldObject to ...
set oldProps to writeable properties of oldObject
make new myClass with properties oldProps

Of course, “writeable properties” is not a valid construct, and so the above leads to a syntax error.

But if I just used “properties”, that would include read-only props, and if I passed those to the “make” command, it would internally complain about trying to set read-only properties.

Any ideas how to solve this elegantly?

I can add new keywords, of course, but I first wanted to see if there are common ways to do that already.

I don’t think there’s such a construct, unfortunately. You could always follow the lead of InDesign, which ignores any errors as long as there is as least one valid property value in the list of properties you pass. It was designed that way to solve the very problem you are trying to address.

Hi Shane,

I’m glad to see I’m not the first running into this challenge, then :slight_smile:

I had considered that solution as well, but didn’t want to allow assigning to read-only properties at all times.

But then I realized that I can tell whether the properties are set during a “make” or “duplicate” command, and now I simply suppress the error during execution of those commands.

But before I did that, I also extended the duplicate command instead, with a new parameter that takes care of what I wanted to achieve. More options for the user, yay! … Which pretty much counters the direction Apple is going, which is to reduce the options to a computer user more and more :wink: