• Isadora
  • Get it
  • Forum
  • Help
  • ADD-ONS
  • Newsletter
  • Impressum
  • Dsgvo
  • Impressum
Forum
    • Categories
    • Recent
    • Popular
    • Tags
    • Register
    • Login

    [ANSWERED] How to limit decimal output in Text Draw

    How To... ?
    4
    11
    273
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • jfgJ
      jfg @Gaspar
      last edited by

      @gaspar

      you can found on the forum this post from @DusX 

      https://community.troikatronix...

      best Jean-François 

      • Izzy 3.2.6, Mac OS 14.1 Sonoma:
      - MacBook Pro M1 Max 16" 64GB RAM
      • Izzy 3.2.6, Mac OS 10.14.6 (Mojave):
      - Mac Pro 5.1 middle 2012 (3,33 GHz 6-Core Intel Xeon, 32GB RAM, Radeon RX 580 8 GB )
      - MacBook Pro 2015 (16GB RAM) 2,8 GHz Intel Core i7;

      Located in Bremen, Germany

      1 Reply Last reply Reply Quote 1
      • MichelM
        Michel Izzy Guru @Gaspar
        last edited by

        @gaspar @jfg

        The Javascript code of @DusX s post did not work for me, but Javascript would sure be the cleanest way. But the approach with the text formatter also works fine. Just paste following into it:  P1:4.2 where 4 is how many number of digits are left of the decimal and 2 how many of digits right of the decimal.

        Best Michel

        Michel Weber | www.filmprojekt.ch | rMBP (2019) i9, 16gig, AMD 5500M 8 GB, OS X 10.15 | located in Winterthur Switzerland.

        jfgJ 1 Reply Last reply Reply Quote 0
        • G
          Gaspar
          last edited by

          @jfg @Michel

          thank you both, since I had the formatter already implemented, I followed that one and it works great.

          However, someday I'll have a look at the Javascript. It looks quite simple and might be a good starting point for learning to implement Javascripts.

          Is there somewhere else, where I could lookm up the formatting commands? Somewhere other than the Izzy manual, from where I could not really understand it (blame it on me).

          Cheers

          Windows 10 64bit version 2004, i7 9700, M.2 SSD for system and SSD 2xRaid for data, 32Gb Ram, nVidia RTX 2070 (mobile) | located in Majorca / Spain

          MichelM 1 Reply Last reply Reply Quote 0
          • MichelM
            Michel Izzy Guru @Gaspar
            last edited by

            @gaspar

            well I don't know were, but I usually use the infos inside Isadora (when hovering with the mouse). But I guess they are not different than the ones in the manual.

            Michel Weber | www.filmprojekt.ch | rMBP (2019) i9, 16gig, AMD 5500M 8 GB, OS X 10.15 | located in Winterthur Switzerland.

            G 1 Reply Last reply Reply Quote 0
            • jfgJ
              jfg @Michel
              last edited by

              @michel

              for me the problem with the javascript is that you don't get the 0 at the end of the decimal. You get 23 and not 23.00 or 23.1 and not 23.10.

              The other problem I have is that you get with both (javascript and text formatter) a dot for decimal and not a comma as usual in Europe. Do you know a way to correct it.

              thanks

              Jean-François 

              • Izzy 3.2.6, Mac OS 14.1 Sonoma:
              - MacBook Pro M1 Max 16" 64GB RAM
              • Izzy 3.2.6, Mac OS 10.14.6 (Mojave):
              - Mac Pro 5.1 middle 2012 (3,33 GHz 6-Core Intel Xeon, 32GB RAM, Radeon RX 580 8 GB )
              - MacBook Pro 2015 (16GB RAM) 2,8 GHz Intel Core i7;

              Located in Bremen, Germany

              MichelM JuriaanJ 2 Replies Last reply Reply Quote 0
              • MichelM
                Michel Izzy Guru @jfg
                last edited by Michel

                @jfg @Gaspar 

                Ok the code from @DusX does work, I just did not realise he put the Javascript into a user actor and therefore I did not change the input value to 2. I added the labelling of the inputs and output, this was added later to the Javascript actor. Well as far as I know JavaScript does not allow comma instead of a point. If you want that you have to convert the output to a string, but then you can't use it as number anymore. Even though Switzerland is in Europe we also use a point instead of a comma.


                // iz_input 1 "float in"
                // iz_input 2 "num of decimals"
                // iz_output 1 "rnd val"
                function main()
                {
                    function Nrnd(num, places){ 
                        return +(Math.round(num + "e+" + places) + "e-" + places);
                    }
                    R = Nrnd(arguments[0],arguments[1]);
                    return R;   
                } 

                Michel Weber | www.filmprojekt.ch | rMBP (2019) i9, 16gig, AMD 5500M 8 GB, OS X 10.15 | located in Winterthur Switzerland.

                1 Reply Last reply Reply Quote 0
                • JuriaanJ
                  Juriaan Tech Staff @jfg
                  last edited by Juriaan

                  @jfg

                  Hi there!

                  Happy to help. You use the JavaScript method .toLocaleString() for this. Basically you give it an valid language like "en-US" and provide the number and the decimals that you prefer.

                  See the example file.

                  Forum Example - Formatted String based on Language

                  JavaScript docs page

                  https://www.w3schools.com/jsre...

                  Valid language parameters

                  ar-SA Arabic (Saudi Arabia)

                  bn-BD Bangla (Bangladesh)

                  bn-IN Bangla (India)

                  cs-CZ Czech (Czech Republic)

                  da-DK Danish (Denmark)

                  de-AT Austrian German

                  de-CH "Swiss" German

                  de-DE Standard German (as spoken in Germany)

                  el-GR Modern Greek

                  en-AU Australian English

                  en-CA Canadian English

                  en-GB British English

                  en-IE Irish English

                  en-IN Indian English

                  en-NZ New Zealand English

                  en-US US English

                  en-ZA English (South Africa)

                  es-AR Argentine Spanish

                  es-CL Chilean Spanish

                  es-CO Colombian Spanish

                  es-ES Castilian Spanish (as spoken in Central-Northern Spain)

                  es-MX Mexican Spanish

                  es-US American Spanish

                  fi-FI Finnish (Finland)

                  fr-BE Belgian French

                  fr-CA Canadian French

                  fr-CH "Swiss" French

                  fr-FR Standard French (especially in France)

                  he-IL Hebrew (Israel)

                  hi-IN Hindi (India)

                  hu-HU Hungarian (Hungary)

                  id-ID Indonesian (Indonesia)

                  it-CH "Swiss" Italian

                  it-IT Standard Italian (as spoken in Italy)

                  ja-JP Japanese (Japan)

                  ko-KR Korean (Republic of Korea)

                  nl-BE Belgian Dutch

                  nl-NL Standard Dutch (as spoken in The Netherlands)

                  no-NO Norwegian (Norway)

                  pl-PL Polish (Poland)

                  pt-BR Brazilian Portuguese

                  pt-PT European Portuguese (as written and spoken in Portugal)

                  ro-RO Romanian (Romania)

                  ru-RU Russian (Russian Federation)

                  sk-SK Slovak (Slovakia)

                  sv-SE Swedish (Sweden)

                  ta-IN Indian Tamil

                  ta-LK Sri Lankan Tamil

                  th-TH Thai (Thailand)

                  tr-TR Turkish (Turkey)

                  zh-CN Mainland China, simplified characters

                  zh-HK Hong Kong, traditional characters

                  zh-TW Taiwan, traditional characters


                  Isadora 3.1.1, Dell XPS 17 9710, Windows 10
                  Interactive Performance Designer, Freelance Artist, Scenographer, Lighting Designer, TroikaTronix Community moderator
                  Always in for chatting about interaction in space / performance design. Drop me an email at hello@juriaan.me

                  JuriaanJ 1 Reply Last reply Reply Quote 1
                  • JuriaanJ
                    Juriaan Tech Staff @Juriaan
                    last edited by Juriaan

                    Also on the Add-on section now 🙂

                    https://troikatronix.com/add-o...

                    Isadora 3.1.1, Dell XPS 17 9710, Windows 10
                    Interactive Performance Designer, Freelance Artist, Scenographer, Lighting Designer, TroikaTronix Community moderator
                    Always in for chatting about interaction in space / performance design. Drop me an email at hello@juriaan.me

                    jfgJ 1 Reply Last reply Reply Quote 1
                    • jfgJ
                      jfg @Juriaan
                      last edited by

                      @juriaan

                      thanks a lot. It works wonderful

                      best, Jean-François 

                      • Izzy 3.2.6, Mac OS 14.1 Sonoma:
                      - MacBook Pro M1 Max 16" 64GB RAM
                      • Izzy 3.2.6, Mac OS 10.14.6 (Mojave):
                      - Mac Pro 5.1 middle 2012 (3,33 GHz 6-Core Intel Xeon, 32GB RAM, Radeon RX 580 8 GB )
                      - MacBook Pro 2015 (16GB RAM) 2,8 GHz Intel Core i7;

                      Located in Bremen, Germany

                      1 Reply Last reply Reply Quote 1
                      • G
                        Gaspar @Michel
                        last edited by

                        @michel Thanks... did miss that this time. It has already helped me. I'm getting friends with the text formatter 😉

                        Windows 10 64bit version 2004, i7 9700, M.2 SSD for system and SSD 2xRaid for data, 32Gb Ram, nVidia RTX 2070 (mobile) | located in Majorca / Spain

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post