7 Replies Latest reply on Oct 17, 2009 8:01 AM by bad mf

    French Number Format

    bad mf

      HI, I want to have the number format be in French: instead of having a comma separating thousands, millions, etc. I want a space. Anybody know the script I could use?

        • 1. Re: French Number Format
          bad mf Level 1

          Found this script but when applied in the "custom" format category, it doesn't seem to do anything... Any ideas?

           

          function number_format(a, b, c, d) {
          // number_format(1234567890, 2, ',', ' ')

          var k = '';
          if(a.indexOf('-') == 0) {
            k = '-';
            a = a * -1;
          }
          a = Math.round(a * Math.pow(10, b)) / Math.pow(10, b);
          var e = a + '';
          var f = e.split('.');
          if(!f[0]) f[0] = '0';
          if(!f[1]) f[1] = '';
          if(f[1].length < b){
            var g = f[1];
            for(var i = f[1].length + 1; i <= b; i++) {
             g += '0';
            }
            f[1] = g;
          }
          if(d != '' && f[0].length > 3) {
            var h = f[0];
            f[0] = '';
            for(var j = 3; j < h.length; j += 3) {
             i = h.slice(h.length - j, h.length - j + 3);
             f[0] = d + i +  f[0] + '';
            }
            j = h.substr(0, (h.length % 3 == 0) ? 3 : (h.length % 3));
            f[0] = j + f[0];
          }
          c = (b <= 0) ? '': c;
          return k + f[0] + c + f[1];
          }

          • 2. Re: French Number Format
            gkaiseril MVP & Adobe Community Professional

            That JavaScirpt defines a callable function, you need to call the the function and supply the necessary parameters and the called function will return the reformatted value.

            1 person found this helpful
            • 3. Re: French Number Format
              bad mf Level 1

              OK, I get what you mean but how would I do this exactly?

              • 4. Re: French Number Format
                MarkWalsh Level 4

                The second line of your script shows an example of how to use that function.

                 

                 

                number_format(1234567890, 2, ',', ' ')

                 

                'number_format(' calls the 'number_format' function. The first number is the value you want formatted, The second parameter is the number of decimal places, the third is the decimal delimiter, and the fourth is the thousands delimiter.
                You can call this function in the Custom Format script like this:

                 

                event.value = number_format(event.value, 2, ',', ' ')

                 

                 

                If you put the number_format code into a document level script, you can call this function from any field.

                • 5. Re: French Number Format
                  bad mf Level 1

                  Ive tried a few ways to call up the script like you say but don't know where to place it (and the other) in the forms format window... I'm using Acrobat 8.

                  • 6. Re: French Number Format
                    gkaiseril MVP & Adobe Community Professional

                    Since you may have multiple fields that need to use this format, the function would be placed as a document level script, Entering Document Scripts by Thom Parker, and then place the call to the function in the "Custom Format Script" on the "Format" tab of the field's property window.

                    • 7. Re: French Number Format
                      bad mf Level 1

                      Thanks a million! Works like a charm.