<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[[ANSWERED] Javascript help]]></title><description><![CDATA[<p>Hi.</p>
<p>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.</p>
<p>I have been using chatGPT but with no success. </p>
<p>This is what I have so far. Any help appreciated.</p>
<p><strong>// Function to continuously check the input values and update the output<br />function continuouslyCheckInput(iz_input1, iz_input2, iz_input3, iz_input4, iz_input5) {<br />    // Get input values<br />    const inputValues = [<br />        parseFloat(iz_input1),<br />        parseFloat(iz_input2),<br />        parseFloat(iz_input3),<br />        parseFloat(iz_input4),<br />        parseFloat(iz_input5)<br />    ];</strong></p>
<p><strong>    // Check if all values are 1<br />    const outputValue = inputValues.every(value =&gt; value === 1) ? 1.0 : 0.0; // Ensure float values are returned<br />    <br />    // Send the output value to the output channel<br />    SendOutlets(outputValue);<br />}</strong></p>]]></description><link>https://community.troikatronix.com/topic/8803/answered-javascript-help</link><generator>RSS for Node</generator><lastBuildDate>Tue, 09 Jun 2026 23:35:27 GMT</lastBuildDate><atom:link href="https://community.troikatronix.com/topic/8803.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 19 Apr 2024 15:56:14 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [ANSWERED] Javascript help on Mon, 22 Apr 2024 15:08:13 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://community.troikatronix.com/uid/2066">@juriaan</a> said:</p>
<blockquote>// 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 &lt; arguments.length; i++) {
    	var value = arguments[i]
    	
    	if (value == 0) {
    		return 0
    	}
	}
<pre><code>return 1
</code></pre>
<p dir="auto">}</p></blockquote><p></p>
<p> Yup this is perfect! Thank you!</p>]]></description><link>https://community.troikatronix.com/post/53935</link><guid isPermaLink="true">https://community.troikatronix.com/post/53935</guid><dc:creator><![CDATA[Skulpture]]></dc:creator><pubDate>Mon, 22 Apr 2024 15:08:13 GMT</pubDate></item><item><title><![CDATA[Reply to [ANSWERED] Javascript help on Mon, 22 Apr 2024 14:27:25 GMT]]></title><description><![CDATA[<p>The code block replaced '=&gt;' with '=&gt;'<br />Don't know why, but it won't let me fix it.</p>]]></description><link>https://community.troikatronix.com/post/53933</link><guid isPermaLink="true">https://community.troikatronix.com/post/53933</guid><dc:creator><![CDATA[DusX]]></dc:creator><pubDate>Mon, 22 Apr 2024 14:27:25 GMT</pubDate></item><item><title><![CDATA[Reply to [ANSWERED] Javascript help on Mon, 22 Apr 2024 08:34:40 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://community.troikatronix.com/uid/2066">@juriaan</a></p><p>That works!</p>]]></description><link>https://community.troikatronix.com/post/53926</link><guid isPermaLink="true">https://community.troikatronix.com/post/53926</guid><dc:creator><![CDATA[bonemap]]></dc:creator><pubDate>Mon, 22 Apr 2024 08:34:40 GMT</pubDate></item><item><title><![CDATA[Reply to [ANSWERED] Javascript help on Mon, 22 Apr 2024 08:32:47 GMT]]></title><description><![CDATA[<p>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</p><p>If all passes it will return a 1.</p><p>Please be aware that you need to make that your values are either 0 or 1</p>]]></description><link>https://community.troikatronix.com/post/53925</link><guid isPermaLink="true">https://community.troikatronix.com/post/53925</guid><dc:creator><![CDATA[Juriaan]]></dc:creator><pubDate>Mon, 22 Apr 2024 08:32:47 GMT</pubDate></item><item><title><![CDATA[Reply to [ANSWERED] Javascript help on Mon, 22 Apr 2024 08:31:51 GMT]]></title><description><![CDATA[<p>Hi all!</p>
<p><span class="Apple-tab-span">	</span></p>
<p>// You can customize the names of your inputs and outputs using comments</p>
<p>// like the ones below. Click the "Help" button and read "Customizing</p>
<p>// Input and Output Names" to learn more.</p>
<p>
</p>
<p>// iz_input 1 "input 1"</p>
<p>// iz_output 1 "all true"</p>
<p>
</p>
<p>function main()</p>
<p>{</p>
<p><span class="Apple-tab-span">	</span>for (let i = 0; i &lt; arguments.length; i++) {</p>
<p>    <span class="Apple-tab-span">	</span>var value = arguments[i]</p>
<p>    <span class="Apple-tab-span">	</span></p>
<p>    <span class="Apple-tab-span">	</span>if (value == 0) {</p>
<p>    <span class="Apple-tab-span">		</span>return 0</p>
<p>    <span class="Apple-tab-span">	</span>}</p>
<p><span class="Apple-tab-span">	</span>}</p>
<p><span class="Apple-tab-span">	</span></p>
<p><span class="Apple-tab-span">	</span>return 1</p>
<p>}</p>
<p></p>]]></description><link>https://community.troikatronix.com/post/53924</link><guid isPermaLink="true">https://community.troikatronix.com/post/53924</guid><dc:creator><![CDATA[Juriaan]]></dc:creator><pubDate>Mon, 22 Apr 2024 08:31:51 GMT</pubDate></item><item><title><![CDATA[Reply to [ANSWERED] Javascript help on Mon, 22 Apr 2024 10:51:02 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://community.troikatronix.com/uid/4">@skulpture</a></p>
<p>Hi,</p>
<p>Here is a non-javascript solution if that is of use. I modified a macro from a current patch I am working on.</p><p>It returns 1 if all inputs are 1 otherwise another value in any input returns a 0.</p>
<p><a href="/assets/uploads/files/1713774312767-trigger-on-data-set-1.iua3">trigger-on-data-set-1.iua3</a></p>
<p></p>
<p><img src="/assets/uploads/files/1713774496106-screenshot-2024-04-22-at-6.26.19-pm.png" style="cursor:pointer" /><br /></p><p></p>
<p>Best Wishes,</p>
<p>Russell</p>]]></description><link>https://community.troikatronix.com/post/53923</link><guid isPermaLink="true">https://community.troikatronix.com/post/53923</guid><dc:creator><![CDATA[bonemap]]></dc:creator><pubDate>Mon, 22 Apr 2024 10:51:02 GMT</pubDate></item><item><title><![CDATA[Reply to [ANSWERED] Javascript help on Mon, 22 Apr 2024 08:05:13 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://community.troikatronix.com/uid/124">@dusx</a> thanks for helping. I get anther error, unfortunately. </p><img src="/assets/uploads/files/1713773096489-screenshot-2024-04-22-090435.png" />]]></description><link>https://community.troikatronix.com/post/53922</link><guid isPermaLink="true">https://community.troikatronix.com/post/53922</guid><dc:creator><![CDATA[Skulpture]]></dc:creator><pubDate>Mon, 22 Apr 2024 08:05:13 GMT</pubDate></item><item><title><![CDATA[Reply to [ANSWERED] Javascript help on Mon, 22 Apr 2024 14:27:06 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://community.troikatronix.com/uid/4">@skulpture</a></p>
<p>try this:</p>
<pre>
// 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);
<pre><code>// Check if all values in the array are exactly 1
const allOnes = values.every(value =&amp;gt; value === 1);
//print(allOnes);

// Return 1 if all values are 1, otherwise return 0
return allOnes ? 1 : 0;
</code></pre>
<p dir="auto">}<br />
function main()<br />
{<br />
return checkValues(arguments);<br />
}</p></pre><p></p>
]]></description><link>https://community.troikatronix.com/post/53916</link><guid isPermaLink="true">https://community.troikatronix.com/post/53916</guid><dc:creator><![CDATA[DusX]]></dc:creator><pubDate>Mon, 22 Apr 2024 14:27:06 GMT</pubDate></item></channel></rss>