<?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[Array returnd from Function]]></title><description><![CDATA[<p dir="auto">I'm not genius in script writing. As of this I do not know what I'm doing wrong.<br />
Using Netxms 4.0-2227 calling a script from scriptlibrary out of Instance discovery filter I'm doing some analyzing of alias-string.<br />
&gt;&gt;&gt; 2022.04.15 22:38:50.538 *I* [nxsl.trace         ] NT_lib_InstDisc::int_InstDisc_01 called with: ##---#hjipeffebguo Fa0/4 (##---#hjipeffebguo)<br />
Within the sub int_InstDisc_01 an other sub is called that should return an array consisting of three values and a string with three characters.<br />
&gt;&gt;&gt; 2022.04.15 22:38:50.538 *I* [nxsl.trace         ] NT_lib_Parsers::Parse_Interface_Alias_Prefix called with: ##---#hjipeffebguo<br />
Using trace function I can figure out that the array will be constructed the right way within called sub Parse_Interface_Alias_Prefix.<br />
&gt;&gt;&gt; 2022.04.15 22:38:50.538 *I* [nxsl.trace         ] NT_lib_Parsers::Parse_Interface_Alias_Prefix returns Values (hashash has2hash hasparams param ):1;1;1;---;<br />
But printing the resulting array within int_InstDisc_01 I only can identify the three values but there is no string to find<br />
&gt;&gt;&gt; 2022.04.15 22:38:50.538 *I* [nxsl.trace         ] In int_InstDisc_01 Return Values from Parse_Interface_Alias_Prefix: 1;1;1;;<br />
Moving the three character-string from the last place in the array a little bit forward within sub Parse_Interface_Alias_Prefix just gave me analogous result without the string in returned array.</p>
<p dir="auto">Is there a restriction concerning mixing of different types for the return array of a sub?</p>
<p dir="auto">For production environment I have the two scripts in different libs. But I build up a test system where I put them in one library to reduce complexity.</p>
<pre><code>Script snipplets:
sub int_InstDisc_01(ifalias,ifname)
{ trace(0,"NT_lib_InstDisc::int_InstDisc_01 called with: ".ifalias." ".ifname);

  inst_disc = false;
  array res1;

  res1 = Parse_Interface_Alias_Prefix(ifalias);
  trace(0,"In int_InstDisc_01 Return Values from Parse_Interface_Alias_Prefix: ".ArrayToString(res1,";").";");
.....
}

sub Parse_Interface_Alias_Prefix(ialias)
{ trace(0,"NT_lib_Parsers::Parse_Interface_Alias_Prefix called with: ".ialias);

  array retval;
....
  retval = %(hashash,has2hash,hasparams,param);
  trace(0,"NT_lib_Parsers::Parse_Interface_Alias_Prefix returns Values (hashash has2hash hasparams param ):".ArrayToString(retval,";").";");
  return(retval);
}
</code></pre>
]]></description><link>https://forum.netxms.org/topic/7354/array-returnd-from-function</link><generator>RSS for Node</generator><lastBuildDate>Fri, 13 Nov 2026 10:38:47 GMT</lastBuildDate><atom:link href="https://forum.netxms.org/topic/7354.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 17 Apr 2022 09:03:49 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Array returnd from Function on Fri, 29 Apr 2022 22:03:25 GMT]]></title><description><![CDATA[<p dir="auto">There was a bug related to use of <em>case</em> operator. It's now fixed, will be included in next release which is planned next week.</p>
]]></description><link>https://forum.netxms.org/post/31278</link><guid isPermaLink="true">https://forum.netxms.org/post/31278</guid><dc:creator><![CDATA[Filipp Sudanov]]></dc:creator><pubDate>Fri, 29 Apr 2022 22:03:25 GMT</pubDate></item><item><title><![CDATA[Reply to Array returnd from Function on Thu, 21 Apr 2022 13:51:36 GMT]]></title><description><![CDATA[<p dir="auto">Hello Filipp,<br />
I followed Your advice and looked at the length of the array in called function and in calling function. Value was the same both times e.g. 4.<br />
Reducing and testing code via calling the script as serverscript from a device. This scriptlib has the subs and a "main"-function that calls the subs. With reduced code resulting string appears in the calling-function. After introducing some more calculation in called function the problem appears once more with the following results:<br />
NT_lib_InstDisc::int_InstDisc_01 called with: ##---#nsnsnsn bhohofewho<br />
NT_lib_Parsers::Parse_Interface_Alias_Prefix called with: ##---#nsnsnsn<br />
Parse_Interface_Alias_Prefix IN default:13 ##---#nsnsnsn<br />
NT_lib_Parsers::Parse_Interface_Alias_Prefix returns Values (hashash;has2hash;hasparams;param;;arraylength):1;1;1;---;;4;<br />
Error 15 in line 37: Unknown object's attribute</p>
<p dir="auto">Some times automatic server-restart followed.</p>
<p dir="auto">Putting a trace command directly in front of building  retval changed situation and function worked as expected.</p>
<p dir="auto">WITH LINE 135 NOT COMMENTED OUT:<br />
NT_lib_InstDisc::int_InstDisc_01 called with: ##---#nsnsnsn bhohofewho<br />
NT_lib_Parsers::Parse_Interface_Alias_Prefix called with: ##---#nsnsnsn<br />
Parse_Interface_Alias_Prefix IN default:13 ##---#nsnsnsn<br />
NT_lib_Parsers::Parse_Interface_Alias_Prefix param:---<br />
NT_lib_Parsers::Parse_Interface_Alias_Prefix returns Values (hashash;has2hash;hasparams;param;;arraylength):1;1;1;---;;4;<br />
In int_InstDisc_01 Return Values from Parse_Interface_Alias_Prefix: 1;1;1;---;;4;</p>
<p dir="auto">As of this You will find complete code I wrote as attachment, because I don't know where my error is.</p>
<p dir="auto">Best regards</p>
<p dir="auto">Georg</p>
<hr />
<p dir="auto"><a href="/assets/uploads/files/smf/0000000005672-parseprefix.nxsl">parseprefix.nxsl</a></p>
]]></description><link>https://forum.netxms.org/post/31247</link><guid isPermaLink="true">https://forum.netxms.org/post/31247</guid><dc:creator><![CDATA[gkaudewitz]]></dc:creator><pubDate>Thu, 21 Apr 2022 13:51:36 GMT</pubDate></item><item><title><![CDATA[Reply to Array returnd from Function on Tue, 19 Apr 2022 15:48:44 GMT]]></title><description><![CDATA[<p dir="auto">This looks strange. I suggest you to minimize the code to get it as short as possible with this bug replicating.</p>
<p dir="auto">Does it acts the same if you do "Execute server script" on any node and put the code there?</p>
<p dir="auto">For debugging you can also trace the number of elements of array, it's size attribute, e.g. retval-&gt;size</p>
]]></description><link>https://forum.netxms.org/post/31238</link><guid isPermaLink="true">https://forum.netxms.org/post/31238</guid><dc:creator><![CDATA[Filipp Sudanov]]></dc:creator><pubDate>Tue, 19 Apr 2022 15:48:44 GMT</pubDate></item></channel></rss>