AutoPatrol, Bureaucrats, Administrators
481
edits
m (Text replacement - "^" to "{{deprecated}}") |
|||
(3 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{DISPLAYTITLE:NetXMS Scripting Language (NXSL)}} | {{deprecated}}{{DISPLAYTITLE:NetXMS Scripting Language (NXSL)}} | ||
{| style="border-spacing: 20px; border: 20px solid red;" | |||
| | |||
'''WARNING''': This page is no longer updated. Please visit '''[https://www.netxms.org/documentation/nxsl-latest/#_language_syntax Language syntax]''' for current version of the documentation. | |||
|} | |||
= NXSL Overview = | = NXSL Overview = | ||
In many parts of the system, fine tuning can be done by using NetXMS built-in scripting language called NXSL (stands for NetXMS Scripting Language). NXSL was designed specifically to be used as embedded scripting language within NetXMS, and because of this has some specific features and limitations. Most notable is very limited access to data outside script boundaries – for example, from NXSL script you cannot access files on server, nor call external programs, nor even access data of the node object other than script is running for without explicit permission. NXSL is interpreted language – scripts first compiled into internal representation (similar to byte code in Java), which than executed inside NXSL VM. | In many parts of the system, fine tuning can be done by using NetXMS built-in scripting language called NXSL (stands for NetXMS Scripting Language). NXSL was designed specifically to be used as embedded scripting language within NetXMS, and because of this has some specific features and limitations. Most notable is very limited access to data outside script boundaries – for example, from NXSL script you cannot access files on server, nor call external programs, nor even access data of the node object other than script is running for without explicit permission. NXSL is interpreted language – scripts first compiled into internal representation (similar to byte code in Java), which than executed inside NXSL VM. | ||
Line 223: | Line 233: | ||
== Array Initialization == | == Array Initialization == | ||
New array can be created in two ways. First is to use '''array''' operator | New array can be created in two ways. First is to use '''array''' operator. <br> | ||
This statement will create empty array and assign reference to it to variable ''a''. | |||
<syntaxhighlight lang="c"> | |||
array a; | |||
</syntaxhighlight> | |||
You can then assign values to the array like this.<br> | |||
Please note arrays in NXSL are sparse, so you can have elements with nothing in between. | |||
<syntaxhighlight lang="c"> | <syntaxhighlight lang="c"> | ||
array a; | array a; | ||
a[1] = 1; | |||
a[2] = 2; | |||
a[260] = 260; | |||
println(a[1]); // will print 1 | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Second way is to use %( ) construct to create array already populated with values.<br> | |||
This statement will create array with four elements at positions 0, 1, 2, and 3, and assign reference to this array to variable ''a''. | |||
<syntaxhighlight lang="c"> | <syntaxhighlight lang="c"> | ||
// no need to use "array a;" here, since we are creating it dirrectly | |||
a = %(1, 2, 3, 4); | a = %(1, 2, 3, 4); | ||
println(a[0]); // will actually print 1, since 1 is the 0th member | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Array initialization can also be used directly in expressions, like this: | |||
<syntaxhighlight lang="c"> | <syntaxhighlight lang="c"> |