Highlighted

Could someone please explain how to use the index() method?

Contributor ,
Apr 22, 2020

Copy link to clipboard

Copied

Could someone please explain how to use the index() method?  The reference says:


app.activeDocument.pathItems.index(itemKey)

Gets an element from the collection.  itemKey is a string or number.


I presumed that it would be similar to getByName(), but returns an object by an array's index

instead.  This doesn't seem to be the case.  For example, if I want to reference "pathItems[2]" in the example below, I get an error.


So what actually is "itemKey" and how does one use the index() method? 

 

Thanks in advance. 

 

var path0 = activeDocument.pathItems.add (); //pathItems[2]
path0.name = "path0";
var path1 = activeDocument.pathItems.add (); //pathItems[1]
path1.name = "path1";
var path2 = activeDocument.pathItems.add (); //pathItems[0]
path2.name = "path2";

alert (activeDocument.pathItems[2].name); //works, i.e. alerts "path0"

var xxx = activeDocument.pathItems.index (2); //doesn't work
alert (xxx.name);

 

Adobe Community Professional
Correct answer by CarlosCanto | Adobe Community Professional

hmm...Interesting, I've never used Index() so I never realized it doesn't work.

do you need to use it or are you just curios?

My guess is that Index is probably an obsolete function that existed in an ancient version of the scripting engine and they forgot to remove it from the Reference.

 

Index is not listed in the OMV so officially it doesn't exist now

OMV-missing_index_method.PNG

 

on the other had, it is still current in the VBS engine. That's why I think it did exist in javascript at some point in its early life.

OMV-vba_index_method.PNG

 

Topics

Scripting

Views

480

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Could someone please explain how to use the index() method?

Contributor ,
Apr 22, 2020

Copy link to clipboard

Copied

Could someone please explain how to use the index() method?  The reference says:


app.activeDocument.pathItems.index(itemKey)

Gets an element from the collection.  itemKey is a string or number.


I presumed that it would be similar to getByName(), but returns an object by an array's index

instead.  This doesn't seem to be the case.  For example, if I want to reference "pathItems[2]" in the example below, I get an error.


So what actually is "itemKey" and how does one use the index() method? 

 

Thanks in advance. 

 

var path0 = activeDocument.pathItems.add (); //pathItems[2]
path0.name = "path0";
var path1 = activeDocument.pathItems.add (); //pathItems[1]
path1.name = "path1";
var path2 = activeDocument.pathItems.add (); //pathItems[0]
path2.name = "path2";

alert (activeDocument.pathItems[2].name); //works, i.e. alerts "path0"

var xxx = activeDocument.pathItems.index (2); //doesn't work
alert (xxx.name);

 

Adobe Community Professional
Correct answer by CarlosCanto | Adobe Community Professional

hmm...Interesting, I've never used Index() so I never realized it doesn't work.

do you need to use it or are you just curios?

My guess is that Index is probably an obsolete function that existed in an ancient version of the scripting engine and they forgot to remove it from the Reference.

 

Index is not listed in the OMV so officially it doesn't exist now

OMV-missing_index_method.PNG

 

on the other had, it is still current in the VBS engine. That's why I think it did exist in javascript at some point in its early life.

OMV-vba_index_method.PNG

 

Topics

Scripting

Views

481

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Enthusiast ,
Apr 23, 2020

Copy link to clipboard

Copied

Bonjour Blanco,

L'index le plus petit [0] est au premier plan (objet.zOrder(ZOrderMethod.BRINGTOFRONT);)

xxx = activeDocument.pathItems[0];

Ne pas utiliser

 

activeDocument.pathItems.index (2)

 

index.PNG

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Adobe Community Professional ,
Apr 23, 2020

Copy link to clipboard

Copied

hmm...Interesting, I've never used Index() so I never realized it doesn't work.

do you need to use it or are you just curios?

My guess is that Index is probably an obsolete function that existed in an ancient version of the scripting engine and they forgot to remove it from the Reference.

 

Index is not listed in the OMV so officially it doesn't exist now

OMV-missing_index_method.PNG

 

on the other had, it is still current in the VBS engine. That's why I think it did exist in javascript at some point in its early life.

OMV-vba_index_method.PNG

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Contributor ,
Apr 24, 2020

Copy link to clipboard

Copied

Thank you both. 

 

I don't need to use it.  I was just curious. 

 

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...