Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Create a property

New Here ,
Jan 12, 2006 Jan 12, 2006
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
TOPICS
Scripting
541
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 12, 2006 Jan 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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 12, 2006 Jan 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.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 12, 2006 Jan 12, 2006
LATEST
@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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines