Skip to main content
Participating Frequently
January 12, 2006
Question

Create a property

  • January 12, 2006
  • 2 replies
  • 617 views
I have an advanced JavaScript Question! As i learned it is possible to add new Functions to existing objects:

Column.prototype.isEmpty = function() { ... }

but how can i add a new property to a existing object???

For Example i want to add a new "minimumWidth " Property to the InDesign "Column" object. I have tried something like:

Column.prototype.minimumWidth = 0;

// var col = ... Get a real Column object from selection ...

col.minimumWidth = 100;
alert( "Column: " + col.minimumWidth );

This code gives the following Error (in InDesign CS2):

"Error: Object does not support the property or method 'minimumWidth'"

The above Code is valid ECMA JavaScript! Any Help???

Thanks Tilo
This topic has been closed for replies.

2 replies

_Debilo_Author
Participating Frequently
January 13, 2006
@Robert: I already have asked this Question in the ID Scripting Forum, with no successful response.

I thought that the Bridge Scripters are experienced JavaScript Scripters. And my question is not totally ID focused. ;-)

@xbytor: So it seems like this is an Adobe Issue.

Thanks! Tilo
Known Participant
January 12, 2006
You should ask this in the InDesign scripting forum!

Adding a property to a prototype will not work, even though adding a method will.

Meanwhile, with JavaScript you need not bother for properties.

var f = new File();
f.myProp = 12;

that will work. Whether or not a property exists at instantiation is inconsequential. If it's not set, it will return undefined either way.

That said, with my limited experience with ID, adding arbitrary properties does not seem to work in the ID environment. It does in Bridge, PS, and others. I do not know what the differences are in implementation. But were I you, I would ask the folks on the ID forum.

Bob
Adobe Workflow Scripting
Known Participant
January 12, 2006
I have a more detailed response on this topic here:
http://ps-scripts.com/bb/viewtopic.php?p=1743#1743

It's a reply to Andrew's previous post in that thread.

Robert_Stucky@adobeforums.com wrote:

> That said, with my limited experience with ID, adding arbitrary properties does not seem to work in the ID environment.

Different rev of the interpreter, maybe? I noticed odd things like this in the
PSCS interpreter but most of that seems to have been cleaned up for PSCS2.