Quantcast
Channel: Adobe Community : Popular Discussions - InDesign Scripting
Viewing all articles
Browse latest Browse all 15932

Script UI 89858 error

$
0
0

Hi everyone

 

I change the script into this

but cause 89858 error

so can some fix this error?

 

Regard

John

 

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++

 

            function doSomething(myEvent1){

               var cSelected = ddown.selection.index;

               if (myEvent1.keyName === "Up") {

                    if (cSelected == ddown.items.length - 1) {

                        ddown.selection = ddown.items[0]; return;

                        }

                     if (ddown.items[cSelected + 1].type == "item") {

                        ddown.selection = ddown.items[cSelected + 1]; return;

                        }

                    else ddown.selection = ddown.items[cSelected + 2];

                    return;

                    }

                 if (myEvent1.keyName === "Down") {

                    if (cSelected == 0) {

                        ddown.selection = ddown.items.length - 1; return;

                        }

                     if (ddown.items[cSelected - 1].type == "item") {

                        ddown.selection = ddown.items[cSelected - 1]; return;

                        }

                    else ddown.selection = ddown.items[cSelected - 2];

                    return;

                    }

            for(var n=0;n<myStringList.length;n++){

                if(myEvent1.keyName === String(Number(myStringList[n].replace(/^0+/,"")))){

                    ddown.selection = n;

                    break;

                        }

                    };

                };  

 

            //Array of strings:

            var myStringList =

                [

                    "1 General",

                    "2 Special",

                    "3 Others"

                ];

           

            var w = new Window ("dialog", "Change by list");

            var ddown = w.add ("dropdownlist", undefined, myStringList);

            ddown.minimumSize.width = 200;

            ddown.selection = 0;

            ddown.active = true;

            w.addEventListener ("keydown", doSomething);

 

 

                b = w.add("group");

                b.add ('button', undefined, "OK", {name: "OK"});

                b.add ('button', undefined, "取り消す", {name: "Cancel"});

 

 

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

 

 

if (w.show() == 1){

  app.selection[0].tables.everyItem().convertToText("\t", "\r");

  main();

 

// dropdown list assigned and return to nothing so cause 89858 error

  }

function main(){

  var myObject;

  var myCheckSelection = false;

  if(app.documents.length > 0){

  if(app.selection.length > 0){

  switch(app.selection[0].constructor.name){

  case "InsertionPoint":

  case "Character":

  case "Word":

  case "TextStyleRange":

  case "Line":

  case "Paragraph":

  case "TextColumn":

  case "Text":

  myObject = app.selection[0];

  if(myObject != "None"){

  myFindChangeByList(myObject, true);

 

 

                            app.findTextPreferences = NothingEnum.nothing;

                            app.findTextPreferences.capitalization = Capitalization.ALL_CAPS;

                            app.findChangeTextOptions.wholeWord = false;

 

 

                            var myFoundItem = app.activeDocument.findText()

 

 

                            for ( i = myFoundItem.length-1; i >= 0 ; i-- )

                            changeUpperCase( myFoundItem[i] );

                            app.findTextPreferences = NothingEnum.nothing;

 

 

                            function changeUpperCase ( myFound )

                            {

  myFound.capitalization = Capitalization.normal;

  myFound.changecase( ChangecaseMode.uppercase );

  }

 

 

  } // if

  } // switch

  } // if

  } // if

  else alert("No documents are open. Please open a document and try again.");

}

function myFindChangeByList(myObject, myCheckSelection){

  var myScriptFileName, myFindChangeFile, myFindChangeFileName, myScriptFile, myResult;

  var myFindChangeArray, myFindPreferences, myChangePreferences, myFindLimit;

  var myStartCharacter, myEndCharacter;

    if (myStringList == 0){

        var myFindChangeFile = myFindFile("/ClearRubbishSupport/FindChangeList[1tab]-E.txt");

    }

    else if (myStringList == 1){

        var myFindChangeFile = myFindFile("/ClearRubbishSupport/ClearRubbish[enrule]_E.txt");

    }

  else if (myStringList == 2){

        var myFindChangeFile = myFindFile("/ClearRubbishSupport/midas&chuangs_E.txt");

    }

  if(myFindChangeFile != null){

        // Because the selection will change as we add/remove characters,

        // we'll need to reset the selection after each pass if we are

        // checking the selection. We'll get the index of the first character

        // in the selection (relative to the start of its parent story) and

        // the index of the last character in the selection (relative to the

        // *end* of the story, and we'll use them later in the script to

        // keep the ends of the selection in place.

  if(myCheckSelection == true){

  var myStart = myObject.characters.item(0).index;

  var myEnd = myObject.characters.item(-1).index;

  var myStory = myObject.parentStory;

  var myStoryEnd = myStory.characters.item(-1).index;

  myEnd = (myStoryEnd - myEnd)+1;

  }

  myFindChangeFile = File(myFindChangeFile);

  var myResult = myFindChangeFile.open("r", undefined, undefined);

  if(myResult == true){

  //Loop through the find/change operations.

  do{

  myLine = myFindChangeFile.readln();

  //Ignore comment lines and blank lines.

  if((myLine.substring(0,4)!="text")||(myLine.substring(0,4)!="grep")||(myLine.substring(0, 5)!="glyph")){

  myFindChangeArray = myLine.split("\t");

  //The first field in the line is the findType string.

  myFindType = myFindChangeArray[0];

  //The second field in the line is the FindPreferences string.

  myFindPreferences = myFindChangeArray[1];

  //The second field in the line is the ChangePreferences string.

  myChangePreferences = myFindChangeArray[2];

  //The fourth field is the range--used only by text find/change.

  myFindChangeOptions = "{includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}";

  switch(myFindType){

  case "text":

  myFindText(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions);

  break;

  case "grep":

  myFindGrep(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions);

  break;

  case "glyph":

  myFindGlyph(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions);

  break;

  }

  if(myCheckSelection == true){

  myStartCharacter = myStory.characters.item(myStart);

  myEndCharacter = myStory.characters.item(-myEnd);

  myObject = myStory.texts.itemByRange(myStartCharacter, myEndCharacter);

  app.select (myObject);

  }

  }

  } while(myFindChangeFile.eof == false);

  myFindChangeFile.close();

  }

  }

}

function myFindText(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions){

  //Reset the find/change preferences before each search.

  app.changeTextPreferences = NothingEnum.nothing;

  app.findTextPreferences = NothingEnum.nothing;

  app.findChangeTextOptions = NothingEnum.nothing;

  var myString = "app.findTextPreferences.properties = "+ myFindPreferences + ";";

  myString += "app.changeTextPreferences.properties = " + myChangePreferences + ";";

  myString += "app.findChangeTextOptions.properties = " + myFindChangeOptions + ";";

  app.doScript(myString, ScriptLanguage.javascript);

  myFoundItems = myObject.changeText();

  //Reset the find/change preferences after each search.

  app.changeTextPreferences = NothingEnum.nothing;

  app.findTextPreferences = NothingEnum.nothing;

  app.findChangeTextOptions = NothingEnum.nothing;

}

function myFindGrep(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions){

  //Reset the find/change grep preferences before each search.

  app.changeGrepPreferences = NothingEnum.nothing;

  app.findGrepPreferences = NothingEnum.nothing;

  app.findChangeGrepOptions = NothingEnum.nothing;

  var myString = "app.findGrepPreferences.properties = "+ myFindPreferences + ";";

  myString += "app.changeGrepPreferences.properties = " + myChangePreferences + ";";

  myString += "app.findChangeGrepOptions.properties = " + myFindChangeOptions + ";";

  app.doScript(myString, ScriptLanguage.javascript);

  var myFoundItems = myObject.changeGrep();

  //Reset the find/change grep preferences after each search.

  app.changeGrepPreferences = NothingEnum.nothing;

  app.findGrepPreferences = NothingEnum.nothing;

  app.findChangeGrepOptions = NothingEnum.nothing;

}

function myFindGlyph(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions){

  //Reset the find/change glyph preferences before each search.

  app.changeGlyphPreferences = NothingEnum.nothing;

  app.findGlyphPreferences = NothingEnum.nothing;

  app.findChangeGlyphOptions = NothingEnum.nothing;

  var myString = "app.findGlyphPreferences.properties = "+ myFindPreferences + ";";

  myString += "app.changeGlyphPreferences.properties = " + myChangePreferences + ";";

  myString += "app.findChangeGlyphOptions.properties = " + myFindChangeOptions + ";";

  app.doScript(myString, ScriptLanguage.javascript);

  var myFoundItems = myObject.changeGlyph();

  //Reset the find/change glyph preferences after each search.

  app.changeGlyphPreferences = NothingEnum.nothing;

  app.findGlyphPreferences = NothingEnum.nothing;

  app.findChangeGlyphOptions = NothingEnum.nothing;

}

function myFindFile(myFilePath){

  var myScriptFile = myGetScriptPath();

  var myScriptFile = File(myScriptFile);

  var myScriptFolder = myScriptFile.path;

  myFilePath = myScriptFolder + myFilePath;

  if(File(myFilePath).exists == false){

  //Display a dialog.

  myFilePath = File.openDialog("Choose the file containing your find/change list");

  }

  return myFilePath;

}

function myGetScriptPath(){

  try{

  myFile = app.activeScript;

  }

  catch(myError){

  myFile = myError.fileName;

  }

  return myFile;

}


Viewing all articles
Browse latest Browse all 15932

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>