• Products
    • Isadora
    • Get It
    • ADD-ONS
    • IzzyCast
    • Get It
  • Forum
  • Help
  • Werkstatt
  • Newsletter
  • Impressum
  • Dsgvo
  • Press
  • Isadora
  • Get It
  • ADD-ONS
  • IzzyCast
  • Get It
  • Press
  • Dsgvo
  • Impressum

Navigation

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Tags

    [ANSWERED] Javascript help

    Troubleshooting and Bug Reports
    4
    9
    1789
    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.
    • Skulpture
      Skulpture Izzy Guru last edited by Juriaan

      Hi.

      I want to create a javascript that will look at 5 incoming float values. If all 5 float values are 1 then output 1. If not then always output a 0.

      I have been using chatGPT but with no success. 

      This is what I have so far. Any help appreciated.

      // Function to continuously check the input values and update the output
      function continuouslyCheckInput(iz_input1, iz_input2, iz_input3, iz_input4, iz_input5) {
          // Get input values
          const inputValues = [
              parseFloat(iz_input1),
              parseFloat(iz_input2),
              parseFloat(iz_input3),
              parseFloat(iz_input4),
              parseFloat(iz_input5)
          ];

          // Check if all values are 1
          const outputValue = inputValues.every(value => value === 1) ? 1.0 : 0.0; // Ensure float values are returned
          
          // Send the output value to the output channel
          SendOutlets(outputValue);
      }

      Graham Thorne | www.grahamthorne.co.uk
      RIG 1: Custom-built PC: Windows 11. Ryzen 7 7700X, RTX3080, 32G DDR5 RAM. 2 x m.2.
      RIG 2: Laptop MSI Vector 16 HX AI: Windows 11, Intel Ultra 9. RTX5070ti, 32G RAM (DDR5 6000htz), NVME M.2 SSD.
      RIG 3: Apple Laptop: rMBP i7, 8gig RAM 256 SSD, HD, OS X 10.12.12

      DusX bonemap 2 Replies Last reply Reply Quote 0
      • DusX
        DusX Izzy Guru @Skulpture last edited by DusX

        @skulpture

        try this:

        // You can customize the names of your inputs and outputs using comments
        // like the ones below. Click the "Help" button and read "Customizing
        // Input and Output Names" to learn more.
        // iz_input 1 "input 1"
        // iz_output 1 "output 1"
        function checkValues(vals) {
            // Convert arguments object to a real array
            const values = Array.from(vals);
            //print(values);
        
        // Check if all values in the array are exactly 1
        const allOnes = values.every(value => value === 1);
        //print(allOnes);
        
        // Return 1 if all values are 1, otherwise return 0
        return allOnes ? 1 : 0;
        

        }
        function main()
        {
        return checkValues(arguments);
        }

        🎛️ TroikaTronix Professional Services
        https://troikatronix.com/professional-services

        🎫 Support Tickets
        https://support.troikatronix.com/support/tickets/new

        💻 Add-ons
        https://troikatronix.com/add-ons/?u=dusx

        🧪 GitHub Projects
        https://github.com/rwebber

        🖥️ Win11 | i7 | RTX 4070 | 32GB RAM | Ontario, Canada

        Skulpture 1 Reply Last reply Reply Quote 1
        • Skulpture
          Skulpture Izzy Guru @DusX last edited by

          @dusx thanks for helping. I get anther error, unfortunately. 

          Graham Thorne | www.grahamthorne.co.uk
          RIG 1: Custom-built PC: Windows 11. Ryzen 7 7700X, RTX3080, 32G DDR5 RAM. 2 x m.2.
          RIG 2: Laptop MSI Vector 16 HX AI: Windows 11, Intel Ultra 9. RTX5070ti, 32G RAM (DDR5 6000htz), NVME M.2 SSD.
          RIG 3: Apple Laptop: rMBP i7, 8gig RAM 256 SSD, HD, OS X 10.12.12

          1 Reply Last reply Reply Quote 0
          • bonemap
            bonemap Izzy Guru @Skulpture last edited by bonemap

            @skulpture

            Hi,

            Here is a non-javascript solution if that is of use. I modified a macro from a current patch I am working on.

            It returns 1 if all inputs are 1 otherwise another value in any input returns a 0.

            trigger-on-data-set-1.iua3


            Best Wishes,

            Russell

            http://bonemap.com | Australia
            Izzy STD 4.1.3 | USB 4.1.3 | + Beta
            MBP 14” 2022 M2 16GB | 26.1 Tahoe
            Mac Studio 2023 M2 Ultra 128GB | 26.1 Tahoe
            Mac Mini 2025 M4 Pro 64GB | 26.1 Tahoe
            MBP 16” 2026 M5 Max 128GB | 26.5 Tahoe

            A range of deployable older Macs

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

              Hi all!

              // You can customize the names of your inputs and outputs using comments

              // like the ones below. Click the "Help" button and read "Customizing

              // Input and Output Names" to learn more.

              // iz_input 1 "input 1"

              // iz_output 1 "all true"

              function main()

              {

              for (let i = 0; i < arguments.length; i++) {

                  var value = arguments[i]

                  

                  if (value == 0) {

                  return 0

                  }

              }

              return 1

              }

              Isadora 4.x, Windows 11 Dell XPS 17 5010 or my MacBook Pro M3 Max (Tahoe)
              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

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

                The above code is something that I use in my projects; really a simple loop that when it finds a 0 automatically breaks and returns a 0

                If all passes it will return a 1.

                Please be aware that you need to make that your values are either 0 or 1

                Isadora 4.x, Windows 11 Dell XPS 17 5010 or my MacBook Pro M3 Max (Tahoe)
                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

                1 Reply Last reply Reply Quote 1
                • bonemap
                  bonemap Izzy Guru @Juriaan last edited by

                  @juriaan

                  That works!

                  http://bonemap.com | Australia
                  Izzy STD 4.1.3 | USB 4.1.3 | + Beta
                  MBP 14” 2022 M2 16GB | 26.1 Tahoe
                  Mac Studio 2023 M2 Ultra 128GB | 26.1 Tahoe
                  Mac Mini 2025 M4 Pro 64GB | 26.1 Tahoe
                  MBP 16” 2026 M5 Max 128GB | 26.5 Tahoe

                  A range of deployable older Macs

                  DusX 1 Reply Last reply Reply Quote 0
                  • DusX
                    DusX Izzy Guru @bonemap last edited by

                    The code block replaced '=>' with '=>'
                    Don't know why, but it won't let me fix it.

                    🎛️ TroikaTronix Professional Services
                    https://troikatronix.com/professional-services

                    🎫 Support Tickets
                    https://support.troikatronix.com/support/tickets/new

                    💻 Add-ons
                    https://troikatronix.com/add-ons/?u=dusx

                    🧪 GitHub Projects
                    https://github.com/rwebber

                    🖥️ Win11 | i7 | RTX 4070 | 32GB RAM | Ontario, Canada

                    1 Reply Last reply Reply Quote 0
                    • Skulpture
                      Skulpture Izzy Guru last edited by

                      @juriaan said:

                      // You can customize the names of your inputs and outputs using comments // like the ones below. Click the "Help" button and read "Customizing // Input and Output Names" to learn more. // iz_input 1 "input 1" // iz_output 1 "all true" function main() { for (let i = 0; i < arguments.length; i++) {     var value = arguments[i]          if (value == 0) {     return 0     } }
                      return 1
                      

                      }

                       Yup this is perfect! Thank you!

                      Graham Thorne | www.grahamthorne.co.uk
                      RIG 1: Custom-built PC: Windows 11. Ryzen 7 7700X, RTX3080, 32G DDR5 RAM. 2 x m.2.
                      RIG 2: Laptop MSI Vector 16 HX AI: Windows 11, Intel Ultra 9. RTX5070ti, 32G RAM (DDR5 6000htz), NVME M.2 SSD.
                      RIG 3: Apple Laptop: rMBP i7, 8gig RAM 256 SSD, HD, OS X 10.12.12

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