<?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[Script help]]></title><description><![CDATA[<p dir="auto">. I have a ModBus device connected to Mango. I have a couple of ModBus Data Points. I then have a Meta Data point referencing the Modbus Data points with the following script.</p>
<pre><code>var a=p1.value;
var le=p9.value;
var re=p10.value;
if (le==true) {
                var x = " Left";
}
else if (re==true) {
                var x = " Right";
}
if (a&gt;0) {
                var y = "Pkey"; 
                var result = y +" "+ a +" "+ x;
}
else if (a==0) {
                var result = "No fault"
else if(typeof(p9.value || p10.value)=='undefined'){var result = "No fault"}

return result;
</code></pre>
<p dir="auto">It works as expected except that it throws undefined errors into the result.</p>
<p dir="auto">No fault	06:44:46	<br />
Pkey 1 undefined	06:44:44	<br />
Pkey 1 Left	06:44:37	<br />
No fault	Feb 09 12:28	<br />
Pkey 1 undefined	Feb 09 12:28	<br />
Pkey 1 Right 	Feb 09 12:28</p>
<p dir="auto">Could anyone possibly assist.</p>
<p dir="auto">Many thanks,</p>
<p dir="auto">Duncan</p>
]]></description><link>https://forum.mango-os.com/topic/1482/script-help</link><generator>RSS for Node</generator><lastBuildDate>Wed, 22 Apr 2026 20:23:53 GMT</lastBuildDate><atom:link href="https://forum.mango-os.com/topic/1482.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 10 Feb 2014 10:17:43 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Script help on Mon, 10 Feb 2014 20:25:22 GMT]]></title><description><![CDATA[<p dir="auto">I think CraziFuzzy does have the root of what's causing that output, but there are some other things you might want to fix in your script,</p>
<pre><code>(typeof(p9.value || p10.value)=='undefined')
</code></pre>
<p dir="auto">will not work, anything that can be logical or'ed tends to be boolean by its very nature. You have to split that into</p>
<pre><code>(typeof(p9.value) == 'undefined' || typeof(p10.value)=='undefined')
</code></pre>
<p dir="auto">There is also no definition for result when a &lt; 0 to return.</p>
]]></description><link>https://forum.mango-os.com/post/8305</link><guid isPermaLink="true">https://forum.mango-os.com/post/8305</guid><dc:creator><![CDATA[phildunlap]]></dc:creator><pubDate>Mon, 10 Feb 2014 20:25:22 GMT</pubDate></item><item><title><![CDATA[Reply to Script help on Mon, 10 Feb 2014 17:41:48 GMT]]></title><description><![CDATA[<p dir="auto">At a quick glance, it looks like you aren't handling when le and re might both be false.  If that is the case, x is never initialized.</p>
]]></description><link>https://forum.mango-os.com/post/8302</link><guid isPermaLink="true">https://forum.mango-os.com/post/8302</guid><dc:creator><![CDATA[CraziFuzzy]]></dc:creator><pubDate>Mon, 10 Feb 2014 17:41:48 GMT</pubDate></item></channel></rss>