2 Replies Latest reply on Feb 16, 2009 6:08 PM by dhishok

    CS2 index script not working with CS3

    dhishok Level 1
      Hi scriptwriters,<br /><br />We are currently working for book index in InDesign CS3. Before we were added the index topics, references to the documents in InDesign CS2 through java script. Now we are trying to use the same script for InDesign CS3. While running the script it shows some error in "text searching". I know that searching method is entirely different from CS2 to CS3. I have tried to solve the script error by modifying the script according to CS3 find text preferences. But I am not able to solve the error, so I have copied the pure CS2 script below. Please find the script below and help me for this by modifying it.<br /><br />//IndexFromArrayList_withOneSubtopic<br /><br />var level=0;<br />try{<br />for(k=0; k<app.documents.length; k++)<br />{<br />var myDoc = app.documents[k];<br />var arr = new Array(), x=0, j=0, i=0;<br />arr = [];<br />arr = ["acceptance", "action", "activity", "Adam and Eve"];<br />var myList, myTopic, myPageRef;<br /><br />level=0;<br />alert(k+1);<br />myList = myDoc.indexes.add(); <br /><br />for(i=0;i<arr.length;i++)<br />{<br />     x = myDoc.search(arr[i],false,false,arr[i]);<br />     if((x.length>0)&(x.length>j))<br />     {<br />          myTopic = myList.topics.add(arr[i]);<br />          myPageRef = myTopic.pageReferences.add(x[j]);<br />          j++; i--;<br />     }<br />     else<br />          j=0;<br />     }<br /><br />//second - level<br />level=1;<br />alert(k+1);<br /><br />arr=[];<br />arr = ["action|vs. desire", "action|agitated", "action|see also karma", "activity|and diseases", "activity|and neuroses", "activity|internal and external"];<br /><br />for(j=0,i=0;i<arr.length;i++)<br />{<br />     x1 = arr[i];<br />     x1 = x1.split("|");<br />     x = myDoc.search(x1[1],false,false,x1[1]);<br />     if((x.length>0)&(x.length>j))<br />     {<br />          try<br />          {<br />               myTopic = myList.topics.item(x1[0]);<br />               myTopic1 = myTopic.topics.add(x1[1]);<br />          }<br />          catch(e)<br />          {<br />               continue;<br />          }<br />          myPageRef = myTopic1.pageReferences.add(x[j]);<br />          <br />          y = x1[1];<br />          y = y.substring(0, 8);<br />          if(y == "see also")<br />               myPageRef.pageReferenceType = PageReferenceType.suppressPageNumbers;<br />          else<br />               myPageRef.pageReferenceType = PageReferenceType.currentPage;<br />          <br />          j++; i--;<br />          }<br />     else<br />          j=0;<br />          }<br />     }<br />}<br />catch(e)<br />{<br />     alert(e);<br />     alert(myDoc.name);<br />}<br /><br />//------------------------------<br /><br />Here the sample text to test the script;<br /><br />The even action feuguercing erit acceptance velit adipis activity nisim and diseases nullupt atincin utpat agitated ut inismodigna Adam and Eve augue dolortie et lut volor si ea faccummodit and neuroses nonulla mconulla internal and external commod eugueros aliquat wisisi.<br /><br />Thanks in advance<br />Thiyagu