<?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[Can't use multiple functions in script?]]></title><description><![CDATA[<p dir="auto">This is not working</p>
<p dir="auto">I create this as a script called SetInitialAttributes, it compiles and saves just fine no errors</p>
<pre><code>// Set initial device attributes
// If an attribute does not exist, will create it with -1 as value
// If attribute already exists, will not change it


sub AirFiber()
{
	if (GetCustomAttribute($node,"TestVar1") == null) SetCustomAttribute($node,"TestVar1",-1);
}

sub AirMax()
{
	if (GetCustomAttribute($node,"TestVar2") == null) SetCustomAttribute($node,"TestVar2",-1);
}
</code></pre>
<p dir="auto">Then I try and execute a function. I start off by testing with this</p>
<pre><code>use SetInitialAttributes;
AirFiber();
</code></pre>
<p dir="auto">Works fine</p>
<p dir="auto">Then I try</p>
<pre><code>use SetInitialAttributes;
AirMax();
</code></pre>
<p dir="auto">And I get "Error 1 in line 13: Data stack underflow"<br />
I tried switching the functions around so that AirMax() is on top i.e.</p>
<pre><code>// Set initial device attributes
// If an attribute does not exist, will create it with -1 as value
// If attribute already exists, will not change it


sub AirMax()
{
	if (GetCustomAttribute($node,"TestVar2") == null) SetCustomAttribute($node,"TestVar2",-1);
}

sub AirFiber()
{
	if (GetCustomAttribute($node,"TestVar1") == null) SetCustomAttribute($node,"TestVar1",-1);
}
</code></pre>
<p dir="auto">And it works fine when I call AirMax() because its the first function. But then I try calling AirFiber() and I get the same thing, error on line 13 data stack underflow</p>
<p dir="auto">Am I doing something wrong? Is it not possible to use more than 1 function in a single script?</p>
<p dir="auto">edit: I think this might be a bug. If I remove the 'SetCustomAttribute' command from both functions and replace it with something like 'println "test";' then I can run both functions just fine. But if I use 'SetCustomAttribute' in the 2nd function it causes the data stack underflow error. I can place lots of 'SetCustomAttribute' commands in the first function and they all run just fine, but when there's 2+ functions and running it on anything other than the first function causes this error</p>
]]></description><link>https://forum.netxms.org/topic/6338/can-t-use-multiple-functions-in-script</link><generator>RSS for Node</generator><lastBuildDate>Fri, 13 Nov 2026 14:55:38 GMT</lastBuildDate><atom:link href="https://forum.netxms.org/topic/6338.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 11 Dec 2019 04:16:49 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Can't use multiple functions in script? on Wed, 11 Dec 2019 21:38:43 GMT]]></title><description><![CDATA[<p dir="auto">Awesome work, thanks guys</p>
]]></description><link>https://forum.netxms.org/post/27131</link><guid isPermaLink="true">https://forum.netxms.org/post/27131</guid><dc:creator><![CDATA[Millenium7]]></dc:creator><pubDate>Wed, 11 Dec 2019 21:38:43 GMT</pubDate></item><item><title><![CDATA[Reply to Can't use multiple functions in script? on Wed, 11 Dec 2019 16:45:03 GMT]]></title><description><![CDATA[<p dir="auto">Just fixed this. Bug is actually in source code parser - it is not related to custom attributes but rather to negative constant passed as function parameter. Fix will be included into next patch release.</p>
<p dir="auto">Best regards,<br />
Victor</p>
]]></description><link>https://forum.netxms.org/post/27130</link><guid isPermaLink="true">https://forum.netxms.org/post/27130</guid><dc:creator><![CDATA[victor]]></dc:creator><pubDate>Wed, 11 Dec 2019 16:45:03 GMT</pubDate></item><item><title><![CDATA[Reply to Can't use multiple functions in script? on Wed, 11 Dec 2019 12:32:30 GMT]]></title><description><![CDATA[<p dir="auto">Yes, it's a bug, looks like automatic cast not working correctly in set custom attribute. Wrap -1 in quite marks and it will work.</p>
<pre><code>// Set initial device attributes
// If an attribute does not exist, will create it with -1 as value
// If attribute already exists, will not change it


sub AirFiber()
{
	if (GetCustomAttribute($node,"TestVar1") == null) SetCustomAttribute($node,"TestVar1","-1");
}

sub AirMax()
{
	if (GetCustomAttribute($node,"TestVar2") == null) SetCustomAttribute($node,"TestVar2","-1");
}
</code></pre>
]]></description><link>https://forum.netxms.org/post/27127</link><guid isPermaLink="true">https://forum.netxms.org/post/27127</guid><dc:creator><![CDATA[alk]]></dc:creator><pubDate>Wed, 11 Dec 2019 12:32:30 GMT</pubDate></item></channel></rss>