19 Replies Latest reply on Jul 1, 2009 4:06 AM by mcolmenero

    Updating an old script for CS3?

    Ken Hutchinson
      I have a script I've been using for years now. I just upgraded to InDesign CS3, and now my script doesn't work anymore. I guess I should have expected as much, since this script is about 4 years old and was originally written for InDesign CS1. I didn't write it myself (Olav was kind enough to do this, thanks Olav!) and I'm really no good at writing these things. Can anyone help me to figure out what needs to be changed, or does this script need to be rewritten entirely?

      The error message I'm getting is as follows:

      'b JavaScript Error!
      'b Error Number: 55
      'b Error String: Object does not support the property or method 'findPreferences'
      b' Line: 45
      b' Source: app.findPreferences.appliedParagraphStyle = app.activeDocument.ParagraphStyles.item (myParagraphStyleName)

      The script in question is shown below.

      //UpdatePrices.js
      //An InDesign CS example script
      //
      //Updates values of all text formatted using a specified paragraph style.
      //
      //If no documents are open, then do nothing.
      if(app.documents.length !=0){
      //If the document does not contain any text, or if the document does not contain any paragraph styles, then do nothing.
      if((app.activeDocument.stories.length != 0)&&(app.activeDocument.paragraphStyles.length > 1)){
      myDisplayDialog();
      }
      }
      function myDisplayDialog(){
      //Get a list of the paragraph style names from the active document (for use in the dialog box).
      var myStyleNameList = new Array;
      for(myStyleCounter = 0; myStyleCounter < app.activeDocument.paragraphStyles.length; myStyleCounter ++){
      if(app.activeDocument.paragraphStyles.item(myStyleCounter).name != "[No paragraph style]"){
      myStyleNameList.push(app.activeDocument.paragraphStyles.item(myStyleCounter).name);
      }
      } var myDialog = app.dialogs.add({name:"UpdatePrices"});
      with(myDialog.dialogColumns.add()){
      with(dialogRows.add()){
      staticTexts.add({staticLabel:"Percentage Change:"});
      var myPercentageField = percentEditboxes.add({editValue:5});
      }
      with(dialogRows.add()){
      staticTexts.add({staticLabel:"Paragraph Style:"});
      var myParagraphStyleDropdown = dropdowns.add({stringList:myStyleNameList, selectedIndex:0});
      }
      }
      var myResult = myDialog.show();
      if(myResult == true){
      //Get the control settings from the dialog box.
      var myPercentage = myPercentageField.editValue;
      var myParagraphStyleName = myStyleNameList[myParagraphStyleDropdown.selectedIndex];
      myDialog.destroy();
      myUpdatePrices(myPercentage, myParagraphStyleName);
      }
      else{
      myDialog.destroy();
      }
      }
      function myUpdatePrices(myPercentage, myParagraphStyleName){
      var myFoundItem, myPrice;
      app.findPreferences = NothingEnum.nothing;
      app.changePreferences = NothingEnum.nothing;
      app.findPreferences.appliedParagraphStyle = app.activeDocument.paragraphStyles.item(myParagraphStyleName);
      var myFoundItems = app.activeDocument.search("");
      myPercentage = (myPercentage + 100)*.01;
      if(myFoundItems.length != 0){
      for(myCounter = myFoundItems.length-1; myCounter >= 0; myCounter --){
      myFoundItem = myFoundItems[myCounter];
      //Check for dollars sign.
      if(myFoundItem.characters.item(0).contents == "$"){
      myFoundItem = myFoundItem.characters.itemByRange(1, -1);
      }
      //Check for a return ending the paragraph.
      if(myFoundItem.characters.item(-1).contents == "\r"){
      myFoundItem = myFoundItem.characters.itemByRange(0, -2);
      }
      //Convert the price.
      myFoundItem.contents = myMakePrice(myFoundItem.contents*myPercentage);
      }
      }
      }
      function myMakePrice(myValue){
      var myString = "" + Math.round(myValue * 100) / 100
      var myIndex = myString.indexOf('.')
      if (myIndex < 0){
      return myString + ".00";
      }
      var myPrice = myString.substring(0, myIndex + 1) + myString.substring(myIndex + 1, myIndex + 3)
      if (myIndex + 2 == myString.length){
      myPrice += "0";
      }
      return myPrice
      }
        • 1. Re: Updating an old script for CS3?
          Ken Hutchinson Level 1
          PS Never mind the 'b and b' at the beginning of each line the error message. That was me trying to bold the lines, and flubbing it fabulously.
          • 2. Re: Updating an old script for CS3?
            Level 1
            Hi Ken,

            Here's an updated version. Using Grep makes this one a lot easier!

            //UpdatePrices.jsx
            
            //An InDesign CS3 JavaScript
            //
            //Updates values of all text formatted using a specified paragraph style.
            //
            main();
            function main(){
            //If no documents are open, then do nothing.
            if(app.documents.length !=0){
              //If the document does not contain any text, or if the document does not contain any paragraph styles, then do nothing.
              if((app.activeDocument.stories.length != 0)&&(app.activeDocument.paragraphStyles.length > 1)){
               myDisplayDialog();
              }
            }
            }
            function myDisplayDialog(){
            //Get a list of the paragraph style names from the active document (for use in the dialog box).
            var myStyleNameList = new Array;
            for(myStyleCounter = 0; myStyleCounter < app.activeDocument.paragraphStyles.length; myStyleCounter ++){
              if((app.activeDocument.paragraphStyles.item(myStyleCounter).name != "[No Paragraph Style]")&&(app.activeDocument.paragraphStyles.item(myStyleCounter).name != "[Basic Paragraph]")){

               myStyleNameList.push(app.activeDocument.paragraphStyles.item(myStyleCounter).name);
              }
            }
            var myDialog = app.dialogs.add({name:"UpdatePrices"});
            with(myDialog.dialogColumns.add()){
              with(dialogRows.add()){
               staticTexts.add({staticLabel:"Percentage Change:"});
               var myPercentageField = percentEditboxes.add({editValue:5});
              }
              with(dialogRows.add()){
               staticTexts.add({staticLabel:"Paragraph Style:"});
               var myParagraphStyleDropdown = dropdowns.add({stringList:myStyleNameList, selectedIndex:0});
              }
            }
            var myResult = myDialog.show();
            if(myResult == true){
              //Get the control settings from the dialog box.
              var myPercentage = myPercentageField.editValue;
              var myParagraphStyleName = myStyleNameList[myParagraphStyleDropdown.selectedIndex];
              myDialog.destroy();
              myUpdatePrices(myPercentage, myParagraphStyleName);
            }
            else{
              myDialog.destroy();
            }
            }
            function myUpdatePrices(myPercentage, myParagraphStyleName){
            var myFoundItem, myPrice;
            app.findGrepPreferences = NothingEnum.nothing;
            app.findGrepPreferences.findWhat = "\\$(\\d*.\\d*)";
            app.findGrepPreferences.appliedParagraphStyle = app.activeDocument.paragraphStyles.item(myParagraphStyleName);
            myPercentage = (myPercentage + 100)*.01;
            var myFoundItems = app.activeDocument.findGrep(true);
            if(myFoundItems.length != 0){
              for(myCounter = 0; myCounter < myFoundItems.length; myCounter ++){
               myFoundItem = myFoundItems[myCounter];
               myStartCharacter = myFoundItem.characters.item(1);
               myEndCharacter = myFoundItem.characters.item(-1);
               myFoundItem = myFoundItems[myCounter].texts.itemByRange(myStartCharacter, myEndCharacter);
               myFoundItem.contents = myMakePrice(myFoundItem.contents*myPercentage);
              }
            }
            app.findGrepPreferences = NothingEnum.nothing;
            }
            function myMakePrice(myValue){
            var myString = "" + Math.round(myValue * 100) / 100;
            var myIndex = myString.indexOf('.');
            if (myIndex < 0){
              return myString + ".00";
            }
            var myPrice = myString.substring(0, myIndex + 1) + myString.substring(myIndex + 1, myIndex + 3);
            if (myIndex + 2 == myString.length){
              myPrice += "0";
            }
            return myPrice;
            }

            Thanks,

            Ole
            • 3. Re: Updating an old script for CS3?
              Ken Hutchinson Level 1
              Thank you, Ole. The new script works beautifully. I'm not sure what "Grep" is, but given the speed in which you responded, I'll take your word for it being easier.

              I'd like to thank you again for writing this script in the first place. As I said in my original post, I've been using it now for about four years. Our product line has grown to over 15,000 individual item numbers, and I print five different versions of our catalogs. Each version represents a different price level, so when the boss says "we need to increase prices, I run this script on five different documents. We also have different groups products identified with separate paragraph styles, so I can implement changes at different levels, according to the product group.

              Needless to say, this script has become a very important tool for me. And this year, with the economy being what it is, we've had more price updates in the last six months than in any full year previously. Without this script, I would be up a creek without a paddle, or even a canoe!
              • 4. Re: Updating an old script for CS3?
                I'm also having a problem with a script that was used in InDesign CS2 and gives an error in CS3. I called Adobe and they referred me to an InDesign scripting website, which is no help at all, since I've never used a script before. Any feedback would be welcome. The error message is:<br /><br />JavaScript Error!<br /><br />Error Number: 55<br />Error String: Object does not support the property or method 'changePreferences'<br />Line: 147<br />Source: app.changePreferences = NothingEnum.nothing;<br /><br />The script file follows:<br /><br />//NewFindChangeList.txt<br />//Data file for use with the TextCleanup.jsx script for InDesign CS3.<br />//<br />//The format of each record in the file is:<br />//findProperties<tab>changeProperties<tab>range<tab>description<br />//<br />//Where:<br />//<tab> is a tab character<br />//<br />//findProperties is a properties record (as text)<br />//<br />//changeProperties is a properties record (as text)<br />//<br />//range is either "all" or "once" (Use "all" with caution, as it is very easy to end up in an infinite loop.<br />//Never use "all" when finding/changing formatting.)<br />//<br />//description is a description of the find/change operation<br />//<br />//Very simple example:<br />//{findText:"  "}     {changeText:" "}     Find all double spaces and replace with single spaces.<br />//<br />//More complex example:<br />//{findText:"^9^9.^9^9"}     {applied character style:"price"}     Find $10.00 to $99.99 and apply the character style "price".<br />//<br />//All InDesign search metacharacters are allowed in the findText properties; all but the wildcards are allowed in the changeText properties.<br />//<br />//More examples:<br />//Red text changes.<br />//{findText:"", strikeThru:true, fillColor:"Red"}     {changeText:"", strikeThru:true, position:superscript, fillColor:"Black",}     once     Red strike.<br />//{findText:"", underline:true, fillColor:app.activeDocument.colors.item("Red")}     {changeText:"", underline:true, position:superscript, fillColor:"Black",}     once     Red underline.<br />//{findText:"", fillColor:color "Red" or active document}     {changeText:"", position:superscript, fillColor:"Black",}     once     Red text.<br />//Blue text changes.<br />//{findText:"", strikeThru:true, fillColor:color "Blue" of active document}     {changeText:"", strikeThru:true, position:subscript, fillColor:"Black",}     once     Blue strike.<br />//{findText:"", underline:true, fillColor:color "Blue" of active document}     {changeText:"", underline:true, position:subscript, fillColor:"Black",}     once     Blue underline.<br />//{findText:"", fillColor:color "Blue" of active document}     {changeText:"", position:subscript, fillColor:"Black",}     once     Blue text.<br />//<br />{findText:"  "}     {changeText:" "}     all     Find all double spaces and replace with single spaces.<br />{findText:"^t^t"}     {changeText:"^t"}     all     Find all double tab characters and replace with single tab characters.<br />{findText:"^p^p"}     {changeText:"^p"}     all     Find all double returns and replace with single returns.<br />{findText:"^p "}     {changeText:"^p"}     all     Find all returns followed by a space and replace with single returns.<br />{findText:" ^p"}     {changeText:"^p"}     all     Find all returns followed by a space and replace with single returns.<br />{findText:"^p^t"}     {changeText:"^p"}     all     Find all returns followed by a tab character and replace with single returns.<br />{findText:" ."}     {changeText:"."}     all     Find all space-period and replace with period.<br />{findText:" ,"}     {changeText:","}     all     Find all space-comma and replace with comma.<br />{findText:" ;"}     {changeText:";"}     all     Find all space-semicolon and replace with semicolon.<br />{findText:" :"}     {changeText:":"}     all     Find all space-colon and replace with colon.<br />{findText:" ?"}     {changeText:"?"}     all     Find all space-question mark and replace with question mark.<br />{findText:"..."}     {changeText:""}     all     Find all triple periods and replace with ellipsis.<br /><br />{findText:""}     {changeText:"  "}     once     Find all em-dashes and replace with a space-en dash-space.<br />{findText:"--"}     {changeText:"  "}     once     Find all dash-dash and replace with space-en dash-space.
                • 5. Re: Updating an old script for CS3?
                  Level 1
                  Hi Carol,

                  That's not the script file--it's the data file for the TextCleanup script.

                  There's a new version of that script--it's called FindChangeByList.jsx. It's installed by default, but some of the early CS3 versions have a bug. It's best to go get the script (and all of the other example scripts) from the InDesign scripting home page, which is listed at the top of this forum. Or you could make sure that your version of the script contains the changes discussed in this thread:

                  http://www.adobeforums.com/webx/.3bbf275d.3bc3ed3c/4

                  I don't think you'll have any problem adding your additions to the new FindChangeList.txt file--it works about the same way as the previous version (though it has more features).

                  Thanks,

                  Ole
                  • 6. Re: Updating an old script for CS3?
                    Level 1
                    Ole,

                    Thanks for the reply. I've learned much since posting my problem. I found the "Adobe InDesign Scripting Tutorial" that has sections called "Script Versioning" and "Targeting". By following those instructions, I was able to modify the CS2 script to work in CS3 without having to rewrite anything or learn about scripting!

                    Carol
                    • 7. Re: Updating an old script for CS3?
                      Ole,
                      I was able to use your script above for a global price change in a Product Catalog (Thank you by the way, it's great!) and I was wondering if you would be able to provide a change in which the prices round off to the whole dollar versus to the cents. (ie. $15*5%=$16 (versus $15.75)

                      Any help you can provide would be much appreciated. While I'm an experienced designer and InDesign user I know very little about scripting.

                      Thanks in advance for any assistance you are able to provide!
                      Adam
                      • 8. Re: Updating an old script for CS3?
                        try67 MVP & Adobe Community Professional
                        Hi Adam,

                        Add Math.round() around your price (assuming it's a number, and not a string with the $ sign in it, for example), and that would do the trick.
                        • 9. Re: Updating an old script for CS3?
                          Level 1
                          Utilizing the code below (provided by Ole) would you be able to tell me what line I should make the change? My pricing does have "$" in everything....will that be a problem? Thanks for the reply.
                          Adam

                          Here is the script I'm using

                          //UpdatePrices.jsx
                          //An InDesign CS3 JavaScript
                          //
                          //Updates values of all text formatted using a specified paragraph style.
                          //
                          main();
                          function main(){
                          //If no documents are open, then do nothing.
                          if(app.documents.length !=0){
                          //If the document does not contain any text, or if the document does not contain any paragraph styles, then do nothing.
                          if((app.activeDocument.stories.length != 0)&&(app.activeDocument.paragraphStyles.length > 1)){
                          myDisplayDialog();
                          }
                          }
                          }
                          function myDisplayDialog(){
                          //Get a list of the paragraph style names from the active document (for use in the dialog box).
                          var myStyleNameList = new Array;
                          for(myStyleCounter = 0; myStyleCounter < app.activeDocument.paragraphStyles.length; myStyleCounter ++){
                          if((app.activeDocument.paragraphStyles.item(myStyleCounter).name != "[No Paragraph Style]")&&(app.activeDocument.paragraphStyles.item(myStyleCounter).name != "[Basic Paragraph]")){

                          myStyleNameList.push(app.activeDocument.paragraphStyles.item(myStyleCounter).name);
                          }
                          }
                          var myDialog = app.dialogs.add({name:"UpdatePrices"});
                          with(myDialog.dialogColumns.add()){
                          with(dialogRows.add()){
                          staticTexts.add({staticLabel:"Percentage Change:"});
                          var myPercentageField = percentEditboxes.add({editValue:5});
                          }
                          with(dialogRows.add()){
                          staticTexts.add({staticLabel:"Paragraph Style:"});
                          var myParagraphStyleDropdown = dropdowns.add({stringList:myStyleNameList, selectedIndex:0});
                          }
                          }
                          var myResult = myDialog.show();
                          if(myResult == true){
                          //Get the control settings from the dialog box.
                          var myPercentage = myPercentageField.editValue;
                          var myParagraphStyleName = myStyleNameList[myParagraphStyleDropdown.selectedIndex];
                          myDialog.destroy();
                          myUpdatePrices(myPercentage, myParagraphStyleName);
                          }
                          else{
                          myDialog.destroy();
                          }
                          }
                          function myUpdatePrices(myPercentage, myParagraphStyleName){
                          var myFoundItem, myPrice;
                          app.findGrepPreferences = NothingEnum.nothing;
                          app.findGrepPreferences.findWhat = "\\$(\\d*.\\d*)";
                          app.findGrepPreferences.appliedParagraphStyle = app.activeDocument.paragraphStyles.item(myParagraphStyleName);
                          myPercentage = (myPercentage + 100)*.01;
                          var myFoundItems = app.activeDocument.findGrep(true);
                          if(myFoundItems.length != 0){
                          for(myCounter = 0; myCounter < myFoundItems.length; myCounter ++){
                          myFoundItem = myFoundItems[myCounter];
                          myStartCharacter = myFoundItem.characters.item(1);
                          myEndCharacter = myFoundItem.characters.item(-1);
                          myFoundItem = myFoundItems[myCounter].texts.itemByRange(myStartCharacter, myEndCharacter);
                          myFoundItem.contents = myMakePrice(myFoundItem.contents*myPercentage);
                          }
                          }
                          app.findGrepPreferences = NothingEnum.nothing;
                          }
                          function myMakePrice(myValue){
                          var myString = "" + Math.round(myValue * 100) / 100;
                          var myIndex = myString.indexOf('.');
                          if (myIndex < 0){
                          return myString + ".00";
                          }
                          var myPrice = myString.substring(0, myIndex + 1) + myString.substring(myIndex + 1, myIndex + 3);
                          if (myIndex + 2 == myString.length){
                          myPrice += "0";
                          }
                          return myPrice;
                          }
                          • 10. Re: Updating an old script for CS3?
                            Level 1
                            Here is the script that was provided.

                            //UpdatePrices.jsx
                            //An InDesign CS3 JavaScript
                            //
                            //Updates values of all text formatted using a specified paragraph style.
                            //
                            main();
                            function main(){
                            //If no documents are open, then do nothing.
                            if(app.documents.length !=0){
                            //If the document does not contain any text, or if the document does not contain any paragraph styles, then do nothing.
                            if((app.activeDocument.stories.length != 0)&&(app.activeDocument.paragraphStyles.length > 1)){
                            myDisplayDialog();
                            }
                            }
                            }
                            function myDisplayDialog(){
                            //Get a list of the paragraph style names from the active document (for use in the dialog box).
                            var myStyleNameList = new Array;
                            for(myStyleCounter = 0; myStyleCounter < app.activeDocument.paragraphStyles.length; myStyleCounter ++){
                            if((app.activeDocument.paragraphStyles.item(myStyleCounter).name != "[No Paragraph Style]")&&(app.activeDocument.paragraphStyles.item(myStyleCounter).name != "[Basic Paragraph]")){

                            myStyleNameList.push(app.activeDocument.paragraphStyles.item(myStyleCounter).name);
                            }
                            }
                            var myDialog = app.dialogs.add({name:"UpdatePrices"});
                            with(myDialog.dialogColumns.add()){
                            with(dialogRows.add()){
                            staticTexts.add({staticLabel:"Percentage Change:"});
                            var myPercentageField = percentEditboxes.add({editValue:5});
                            }
                            with(dialogRows.add()){
                            staticTexts.add({staticLabel:"Paragraph Style:"});
                            var myParagraphStyleDropdown = dropdowns.add({stringList:myStyleNameList, selectedIndex:0});
                            }
                            }
                            var myResult = myDialog.show();
                            if(myResult == true){
                            //Get the control settings from the dialog box.
                            var myPercentage = myPercentageField.editValue;
                            var myParagraphStyleName = myStyleNameList[myParagraphStyleDropdown.selectedIndex];
                            myDialog.destroy();
                            myUpdatePrices(myPercentage, myParagraphStyleName);
                            }
                            else{
                            myDialog.destroy();
                            }
                            }
                            function myUpdatePrices(myPercentage, myParagraphStyleName){
                            var myFoundItem, myPrice;
                            app.findGrepPreferences = NothingEnum.nothing;
                            app.findGrepPreferences.findWhat = "\\$(\\d*.\\d*)";
                            app.findGrepPreferences.appliedParagraphStyle = app.activeDocument.paragraphStyles.item(myParagraphStyleName);
                            myPercentage = (myPercentage + 100)*.01;
                            var myFoundItems = app.activeDocument.findGrep(true);
                            if(myFoundItems.length != 0){
                            for(myCounter = 0; myCounter < myFoundItems.length; myCounter ++){
                            myFoundItem = myFoundItems[myCounter];
                            myStartCharacter = myFoundItem.characters.item(1);
                            myEndCharacter = myFoundItem.characters.item(-1);
                            myFoundItem = myFoundItems[myCounter].texts.itemByRange(myStartCharacter, myEndCharacter);
                            myFoundItem.contents = myMakePrice(myFoundItem.contents*myPercentage);
                            }
                            }
                            app.findGrepPreferences = NothingEnum.nothing;
                            }
                            function myMakePrice(myValue){
                            var myString = "" + Math.round(myValue * 100) / 100;
                            var myIndex = myString.indexOf('.');
                            if (myIndex < 0){
                            return myString + ".00";
                            }
                            var myPrice = myString.substring(0, myIndex + 1) + myString.substring(myIndex + 1, myIndex + 3);
                            if (myIndex + 2 == myString.length){
                            myPrice += "0";
                            }
                            return myPrice;
                            }
                            • 11. Re: Updating an old script for CS3?
                              try67 MVP & Adobe Community Professional
                              Hi Adam,

                              I think you need to change this:

                              var myString = "" + Math.round(myValue * 100) / 100;

                              To this:

                              var myString = "" + Math.round(myValue);

                              Basically, whoever wrote the script used the Math.round() function to replace the Math.toFixed() function to produce a number rounded to the second decimal point. By changing it, the result should be a rounded integer.
                              • 12. Re: Updating an old script for CS3?
                                Level 1
                                That works!
                                I did have to remove the ".00" in the line below, but simple enough.
                                Thanks so much!
                                • 13. Re: Updating an old script for CS3?
                                  Level 1
                                  OK, problem. I have several prices that are over $1,000 and they all have a comma designating the thousand dollar mark (ie. $1,000 versus $1000). All of those prices showed up as "$NaN". Is there anything I can do to fix this?

                                  Thanks again for any assistance you can provide. It's much appreciated.
                                  • 14. Re: Updating an old script for CS3?
                                    try67 MVP & Adobe Community Professional
                                    This problem should have occurred even before this change, because the contents of myFoundItem should not have changed.
                                    The way to fix it is to get rid of the comma's, like so:
                                    Replace this line:

                                    myFoundItem.contents = myMakePrice(myFoundItem.contents*myPercentage);

                                    with this:

                                    myFoundItem.contents = myMakePrice(myFoundItem.contents.replace(/,/gi, "")*myPercentage);

                                    (If it doesn't work, put the replace function outside of the function call)

                                    Now, if you want to add the comma's after calculating the new value, you should probably make a loop that goes over the new string and inserts a comma after every 3 characters (starting from the last one and going back to the beginning, of course).
                                    • 15. Re: Updating an old script for CS3?
                                      Level 1
                                      The problem probably would have occurred had I run the test on pricing that was over $1000 but I hadn't.

                                      The line you gave me didn't work and I'm not exactly sure what you mean by "put the replace function outside of the function call". Can you please give me the line so I can copy and paste it?

                                      I would like to be able to keep the commas if at all possible so if you could give me that line and let me know where to put it that would be great as well.

                                      Again, thank you....I'm clueless when it comes to writing code.
                                      • 16. Re: Updating an old script for CS3?
                                        try67 MVP & Adobe Community Professional
                                        This is for removing the comma's:
                                        tmpString = myFoundItem.contents.replace(/,/gi, "");
                                        myFoundItem.contents = myMakePrice(tmpString*myPercentage);

                                        As for putting the comma's back in, you will need to wait a bit as I don't have the time to write it right now.
                                        • 17. Re: Updating an old script for CS3?
                                          try67 MVP & Adobe Community Professional
                                          OK, so if myMakePrice is the function that returns the new price, and myFoundItem.contents should hold the new value after adding the comma's back to it, you should do as follows:

                                          tmpStr = myMakePrice(myFoundItem.contents*myPercentage);
                                          newStr = "";

                                          for (i=1; i<=tmpStr.length; i++) {
                                          newStr = tmpStr.substring(tmpStr.length-i,tmpStr.length-i+1)+newStr;
                                          if ((i%3)==0 && i!=tmpStr.length) {
                                          newStr = "," + newStr;
                                          }
                                          }

                                          myFoundItem.contents = newStr;
                                          • 18. Re: Updating an old script for CS3?
                                            mcolmenero Level 1

                                            Hi,

                                            I want to use this script but i use four different format for prices.

                                            Table A and B: 1000,10 or 1000.10, this form make good

                                            Table C: 1.000,10 this format make bad

                                            Table D: 1,000.10 this format make bad.

                                            Could you help me please? How do I make this script to go on with four format?

                                            Thanks

                                            Best regards

                                            Miguel

                                            • 19. Re: Updating an old script for CS3?
                                              mcolmenero Level 1

                                              hi,

                                              When I paste the code and run, it say me that "replace is not a function".

                                              I have Indesign CS3.

                                              Could you help me please?

                                              thanks

                                              Miguel