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

Indexing by own list

Participant ,
Feb 10, 2025 Feb 10, 2025

Hi.

In the first step I try to load a text-based list to create an index with certain topics. The loading is not the problem:

 

var myDoc = app.activeDocument;

app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Funktionsprozess");

function main() {
	var myList = File.openDialog ("Indexliste laden"); 
	if (!myList) exit(); 

			myList.open ('r', undefined, undefined); 
			var theText = myList.read();//+'\n'; 
			theText = theText.replace(/ +\n/g, '\n').replace(/\n+/g, '\n'); 
			var words = theText //.replace(/\s+/g, '\n');  
	
			var words = theText.split("\n"); 
			listLength = words.length;

			myList.close(); 

	function makeMyList() { 
		app.documents.everyItem().indexes.everyItem().topics.everyItem().remove()

		newIndex = myDoc.indexes.add()
	
		for (var i = 0; i<listLength; i++){  
			myWord = words[i];			
			if (myWord != "") {

				newTopic = myDoc.indexes[0].topics.add (myWord);
				myDoc.indexes[0].topics.add(myWord);


				myDoc.indexes[0].update(); 
			}
		} 
	}
	makeMyList();
		
}​

 

I had to change the script because making a mistake (wanted to use a string instead an array for the enties)🙂Now it works but I also need the page numbers. This is how it looks like:
Bildschirmfoto 2025-02-11 um 14.42.19.png

 

 

 

 

 

 

 

But I´m afraid, the imported topics needs to be at the references (Verweise) instead of the theme (Thema) to get the page numbers, isn´t it?

 

TOPICS
Scripting
903
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 Expert ,
Feb 26, 2025 Feb 26, 2025

I know what "count" means, but the double underline confused me.

 

It's just part of the script language's formalism.

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