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

[JS] CC2017 .topics.add

Enthusiast ,
Apr 13, 2017 Apr 13, 2017

Copy link to clipboard

Copied

Bonjour à tous,

Je ne parviens plus à créer un index avec CC2017

function addTopic() {

var doc = app.documents[0];

        //var monTest = app.selection[0].contents;

    var new_topic = doc.indexes[0].topics.add (app.selection[0].contents);

          

    new_topic.pageReferences.add (app.selection[0], PageReferenceType.currentPage);

}

Cette commande me renvoie une erreur !

Merci pour votre aide

Philippe

TOPICS
Scripting

Views

382

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
community guidelines
Community Expert ,
Apr 13, 2017 Apr 13, 2017

Copy link to clipboard

Copied

Please always state the exact error message you get. "An error" is totally not helpful.

Apart from that, there are several clear errors I can already spot.

1. Your braces do not match (wrong on line 1).

2. "silence" is not a property I recognize.

3. Didn't look it up but I don't thing "Add" is a known function, because (probably) all standard functions start with a lowercase letter.

Votes

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
community guidelines
Enthusiast ,
Apr 13, 2017 Apr 13, 2017

Copy link to clipboard

Copied

Bonjour et Merci Jongware pour c'est remarque très juste ...

Voici mon erruer "Object is Invalid"

Je n'ai pas vérifié si j'avais un index !!!! voilà l'erreur.

  if (myDoc.indexes.length == 0)  {

            myDoc.indexes.add (); 

        }

Merci

Votes

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
community guidelines
Community Expert ,
Apr 13, 2017 Apr 13, 2017

Copy link to clipboard

Copied

LATEST

[Ow -- je suis très désolé! My French lessons are several decades ago and so I tend to hit "Translate" if I'm not sure I get the message. I also did not spot that your original "add" gets 'translated' to "Add", suddenly gaining a capital! So please ignore those remarks.]

Votes

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
community guidelines
Community Expert ,
Apr 13, 2017 Apr 13, 2017

Copy link to clipboard

Copied

Hi Jongware,

the OP never used property "silence" with the code.
This is an error of the forum's Translate feature if you go from French to English ( sigh!).

In the original version there is "contents"…

Regards,
Uwe

Votes

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
community guidelines
People's Champ ,
Apr 13, 2017 Apr 13, 2017

Copy link to clipboard

Copied

Wow the translation engine is creative, "contents" in french would be litterally "happy people". I can't see how it coud be converted to "silence"

Votes

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
community guidelines
Community Expert ,
Apr 13, 2017 Apr 13, 2017

Copy link to clipboard

Copied

Hi Loic,

yes. Funny, isn't it?
Jive must not translate anything that's formatted as code.
But apparently…
( Arrgh!!! )

Regards,
Uwe

Votes

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
community guidelines
People's Champ ,
Apr 13, 2017 Apr 13, 2017

Copy link to clipboard

Copied

You are presuming an index exists by using doc.indexes[0]

Are you sure about that ?

function addTopic() { 

 

var doc = app.documents[0]; 

     

  //Referencing the first index in the collection

  var myIndex = doc.indexes[0];

  //Trying to resolve the reference and if not found, creates a new index instance

  !myIndex.isValid && myIndex = doc.indexes.add();

    var new_topic = doc.indexes[0].topics.add (app.selection[0].contents); 

            

    new_topic.pageReferences.add (app.selection[0], PageReferenceType.currentPage); 

addTopic();

Votes

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
community guidelines
Enthusiast ,
Apr 13, 2017 Apr 13, 2017

Copy link to clipboard

Copied

Exacte Loic

Votes

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
community guidelines