<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.netio-products.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Jturon</id>
	<title>wiki.netio-products.com - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.netio-products.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Jturon"/>
	<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=Special:Contributions/Jturon"/>
	<updated>2026-04-25T20:59:57Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.32.0</generator>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=NETIO_Lua_Manual&amp;diff=367</id>
		<title>NETIO Lua Manual</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=NETIO_Lua_Manual&amp;diff=367"/>
		<updated>2017-05-06T08:34:56Z</updated>

		<summary type="html">&lt;p&gt;Jturon: /* Data types and variables */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Debugging ==&lt;br /&gt;
To debug your code, use [[Function log()|log()]] and [[Function logf()|logf()]] functions. See the output in system events log.&lt;br /&gt;
&lt;br /&gt;
== Data types and variables ==&lt;br /&gt;
Lua supports these data types:&lt;br /&gt;
* &amp;lt;i&amp;gt;nil&amp;lt;/i&amp;gt; (to assign &amp;lt;i&amp;gt;nil&amp;lt;/i&amp;gt; value effectively deletes the variable)&lt;br /&gt;
* &amp;lt;i&amp;gt;boolean&amp;lt;/i&amp;gt; (falsy values are &amp;lt;i&amp;gt;nil&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;false&amp;lt;/i&amp;gt; only; &amp;quot;&amp;quot; and 0 evaluates as &amp;lt;i&amp;gt;true&amp;lt;/i&amp;gt;)&lt;br /&gt;
* &amp;lt;i&amp;gt;number&amp;lt;/i&amp;gt; (decimals only in standard Lua, integers only in Netio Lua)&lt;br /&gt;
* &amp;lt;i&amp;gt;string&amp;lt;/i&amp;gt; (same strings share same address, so equality operator measures both address and value)&lt;br /&gt;
* &amp;lt;i&amp;gt;tables&amp;lt;/i&amp;gt; are associative arrays. (Tables with numeric indices are, well, just arrays.)&lt;br /&gt;
&lt;br /&gt;
 local numbers = {2,3,7,5} -- array (first index = 1)&lt;br /&gt;
 local dictionary = {one=1, two=2, three=3} -- table&lt;br /&gt;
 local numbersZeroBased = {[0]=2,3,7,5} -- array (first index = 0)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;local&amp;lt;/i&amp;gt; keyword limits the variable scope to the block (ended by &amp;lt;i&amp;gt;end&amp;lt;/i&amp;gt;) where it is declared. To access an &amp;lt;i&amp;gt;upvalue&amp;lt;/i&amp;gt; (variable defined outside of the scope), just omit the &amp;lt;i&amp;gt;local&amp;lt;/i&amp;gt; keyword.&lt;br /&gt;
&lt;br /&gt;
== Operators ==&lt;br /&gt;
Lua has its own manners:&lt;br /&gt;
* &amp;lt;code&amp;gt;~=&amp;lt;/code&amp;gt; is inequality operator&lt;br /&gt;
* &amp;lt;code&amp;gt;..&amp;lt;/code&amp;gt; is string concatenation (don't use plus)&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;s&amp;gt;i++&amp;lt;/s&amp;gt;&amp;lt;/code&amp;gt; no increment/decrement operator &amp;lt;code&amp;gt;i = i + 1&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;s&amp;gt;max = a&amp;lt;b ? b : a&amp;lt;/s&amp;gt;&amp;lt;/code&amp;gt; no ternary operator. Use (and get used to) &amp;lt;i&amp;gt;and idiom&amp;lt;/i&amp;gt; instead: &amp;lt;code&amp;gt;max = (a&amp;lt;b) and b or a&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;i&amp;gt;or idiom&amp;lt;/i&amp;gt; works: &amp;lt;code&amp;gt;x = x or 42&amp;lt;/code&amp;gt; is equivalent to &amp;lt;code&amp;gt;if not x then x = 42 end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Conditions ==&lt;br /&gt;
Lua conditions has casual syntax, see [https://www.lua.org/pil/4.3.1.html here]. Just keep in mind to merge &amp;lt;code&amp;gt;else&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;elseif&amp;lt;/code&amp;gt; or multiple &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt;s are required.&lt;br /&gt;
&lt;br /&gt;
Note that falsy values are &amp;lt;i&amp;gt;nil&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;false&amp;lt;/i&amp;gt; only. Empty string and 0 evaluates as true. If you come from C, you might be surprised by following snippet:&lt;br /&gt;
&lt;br /&gt;
 if devices.system.output1_consumption then&lt;br /&gt;
   -- always happens, even if the consumption is 0&lt;br /&gt;
   log(&amp;quot;Outlet 1 supplies power&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 if not devices.system.output1_consumption then&lt;br /&gt;
   -- never happens, even if the consumption is 0&lt;br /&gt;
   log(&amp;quot;Outlet 1 is idle&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
== Loops ==&lt;br /&gt;
Lua has &amp;lt;code&amp;gt;break&amp;lt;/code&amp;gt; statement, but no &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt; (use condition inside loop instead). Additionally, Netio Lua implementation limits the loop iterations to 32k.&lt;br /&gt;
&lt;br /&gt;
=== While ===&lt;br /&gt;
While syntax is not different to other languages:&lt;br /&gt;
 local i = 0&lt;br /&gt;
 while i~=3 do&lt;br /&gt;
   i = i + 1&lt;br /&gt;
   logf(&amp;quot;%d&amp;quot;,i)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
=== Repeat until ===&lt;br /&gt;
Repeat until syntax is the same as Pascal's, other languages have similar do-while loops:&lt;br /&gt;
 local i = 0&lt;br /&gt;
 repeat&lt;br /&gt;
   i = i + 1&lt;br /&gt;
   logf(&amp;quot;%d&amp;quot;,i)&lt;br /&gt;
 until i==3&lt;br /&gt;
&lt;br /&gt;
=== Numeric for ===&lt;br /&gt;
Arrays in Lua are one-based (in indices are not specified, the first one is 1, not 0).&lt;br /&gt;
 local arr = {2,3,7,5}&lt;br /&gt;
 for i=1,#arr do logf(&amp;quot;%d&amp;quot;,arr[i]) end&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;b&amp;gt;for&amp;lt;/b&amp;gt; initVar,limit,increment &amp;lt;b&amp;gt;do&amp;lt;/b&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;i&amp;gt;number assignment&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;initVar&amp;lt;/code&amp;gt; inits loop-local variable&lt;br /&gt;
* &amp;lt;i&amp;gt;number&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;limit&amp;lt;/code&amp;gt; loops until initVar reaches this value&lt;br /&gt;
* &amp;lt;i&amp;gt;optional number&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;increment&amp;lt;/code&amp;gt; after each loop initVar increment by this value (default 1)&lt;br /&gt;
&lt;br /&gt;
=== Generic for ===&lt;br /&gt;
Is rather sophisticated. Most common example (the order of elements in &amp;lt;code&amp;gt;pairs()&amp;lt;/code&amp;gt; is not guaranteed):&lt;br /&gt;
 local tab = {one=1, two=2, three=3}&lt;br /&gt;
 for key,val in pairs(tab) do logf(&amp;quot;%s:%d&amp;quot;,key,val) end&lt;br /&gt;
Generic for syntax&lt;br /&gt;
 &amp;lt;b&amp;gt;for&amp;lt;/b&amp;gt; var_1, ..., var_n &amp;lt;b&amp;gt;in&amp;lt;/b&amp;gt; explist &amp;lt;b&amp;gt;do&amp;lt;/b&amp;gt; block end&lt;br /&gt;
is equivalent to (Full explanation [https://www.lua.org/pil/7.2.html here].)&lt;br /&gt;
 do&lt;br /&gt;
   local _f, _s, _var = explist&lt;br /&gt;
   while true do&lt;br /&gt;
     local var_1, ... , var_n = _f(_s, _var)&lt;br /&gt;
     _var = var_1&lt;br /&gt;
     if _var == nil then break end&lt;br /&gt;
     block&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Iterator closure that holds its state&lt;br /&gt;
 function iter(a)&lt;br /&gt;
   local i = 0&lt;br /&gt;
   return function()&lt;br /&gt;
     i = i+1&lt;br /&gt;
     return a[i]&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 local arr = {2,3,7,5}&lt;br /&gt;
 for value in iter(arr) do&lt;br /&gt;
   logf(&amp;quot;%d&amp;quot;,value)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Stateless iterator (in this case returns variable list: key and value)&lt;br /&gt;
 function iter(a,i)&lt;br /&gt;
   i = i+1&lt;br /&gt;
   if a[i] then return i,a[i] end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 local arr = {2,3,7,5}&lt;br /&gt;
 for k,v in iter,arr,0 do&lt;br /&gt;
   logf(&amp;quot;%d:%d&amp;quot;,k,v)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Same effect using &amp;lt;code&amp;gt;ipairs()&amp;lt;/code&amp;gt; Lua function (without initial state)&lt;br /&gt;
 for k,v in ipairs(arr) do&lt;br /&gt;
   logf(&amp;quot;%d:%d&amp;quot;,k,v)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Now return to the most common example above using &amp;lt;code&amp;gt;pairs()&amp;lt;/code&amp;gt; Lua function and read about &amp;lt;code&amp;gt;pairs()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;ipairs()&amp;lt;/code&amp;gt; implementation [https://www.lua.org/pil/7.3.html here].&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
&lt;br /&gt;
Lua allows multiple results (comma separated):&lt;br /&gt;
&lt;br /&gt;
 function diskSpace()&lt;br /&gt;
   return devices.system.freeSpace, devices.system.totalSpace&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 logf(&amp;quot;Free space: %d MB&amp;quot;, diskSpace()) -- only first return value is used&lt;br /&gt;
 local free,total = diskSpace() -- values are stored into LHS var-list&lt;br /&gt;
 logf(&amp;quot;Free space: %d %%&amp;quot;, 100*free/total)&lt;br /&gt;
&lt;br /&gt;
Variable-length arguments are also available:&lt;br /&gt;
&lt;br /&gt;
 function sum(...)&lt;br /&gt;
   local result = 0&lt;br /&gt;
   for _,v in ipairs(arg) do&lt;br /&gt;
     result = result + v&lt;br /&gt;
   end&lt;br /&gt;
   return result&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 logf(&amp;quot;Sum: %d&amp;quot;, sum(2,3,5))&lt;/div&gt;</summary>
		<author><name>Jturon</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=NETIO_Lua_Manual&amp;diff=366</id>
		<title>NETIO Lua Manual</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=NETIO_Lua_Manual&amp;diff=366"/>
		<updated>2017-05-06T08:16:10Z</updated>

		<summary type="html">&lt;p&gt;Jturon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Debugging ==&lt;br /&gt;
To debug your code, use [[Function log()|log()]] and [[Function logf()|logf()]] functions. See the output in system events log.&lt;br /&gt;
&lt;br /&gt;
== Data types and variables ==&lt;br /&gt;
Lua supports these data types:&lt;br /&gt;
* &amp;lt;i&amp;gt;nil&amp;lt;/i&amp;gt; (to assign &amp;lt;i&amp;gt;nil&amp;lt;/i&amp;gt; value effectively deletes the variable)&lt;br /&gt;
* &amp;lt;i&amp;gt;boolean&amp;lt;/i&amp;gt; (falsy values are &amp;lt;i&amp;gt;nil&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;false&amp;lt;/i&amp;gt; only; &amp;quot;&amp;quot; and 0 evaluates as &amp;lt;i&amp;gt;true&amp;lt;/i&amp;gt;)&lt;br /&gt;
* &amp;lt;i&amp;gt;number&amp;lt;/i&amp;gt; (decimals only in standard Lua, integers only in Netio Lua)&lt;br /&gt;
* &amp;lt;i&amp;gt;string&amp;lt;/i&amp;gt; (same strings share same address, so equality operator measures both address and value)&lt;br /&gt;
* &amp;lt;i&amp;gt;tables&amp;lt;/i&amp;gt; are associative arrays. (Tables with numeric indices are, well, just arrays.)&lt;br /&gt;
&lt;br /&gt;
 local numbers = {2,3,7,5} -- array (first index = 1)&lt;br /&gt;
 local dictionary = {one=1, two=2, three=3} -- table&lt;br /&gt;
 local numbersZeroBased = {[0]=2,3,7,5} -- array (first index = 0)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Operators ==&lt;br /&gt;
Lua has its own manners:&lt;br /&gt;
* &amp;lt;code&amp;gt;~=&amp;lt;/code&amp;gt; is inequality operator&lt;br /&gt;
* &amp;lt;code&amp;gt;..&amp;lt;/code&amp;gt; is string concatenation (don't use plus)&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;s&amp;gt;i++&amp;lt;/s&amp;gt;&amp;lt;/code&amp;gt; no increment/decrement operator &amp;lt;code&amp;gt;i = i + 1&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;s&amp;gt;max = a&amp;lt;b ? b : a&amp;lt;/s&amp;gt;&amp;lt;/code&amp;gt; no ternary operator. Use (and get used to) &amp;lt;i&amp;gt;and idiom&amp;lt;/i&amp;gt; instead: &amp;lt;code&amp;gt;max = (a&amp;lt;b) and b or a&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;i&amp;gt;or idiom&amp;lt;/i&amp;gt; works: &amp;lt;code&amp;gt;x = x or 42&amp;lt;/code&amp;gt; is equivalent to &amp;lt;code&amp;gt;if not x then x = 42 end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Conditions ==&lt;br /&gt;
Lua conditions has casual syntax, see [https://www.lua.org/pil/4.3.1.html here]. Just keep in mind to merge &amp;lt;code&amp;gt;else&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;elseif&amp;lt;/code&amp;gt; or multiple &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt;s are required.&lt;br /&gt;
&lt;br /&gt;
Note that falsy values are &amp;lt;i&amp;gt;nil&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;false&amp;lt;/i&amp;gt; only. Empty string and 0 evaluates as true. If you come from C, you might be surprised by following snippet:&lt;br /&gt;
&lt;br /&gt;
 if devices.system.output1_consumption then&lt;br /&gt;
   -- always happens, even if the consumption is 0&lt;br /&gt;
   log(&amp;quot;Outlet 1 supplies power&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 if not devices.system.output1_consumption then&lt;br /&gt;
   -- never happens, even if the consumption is 0&lt;br /&gt;
   log(&amp;quot;Outlet 1 is idle&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
== Loops ==&lt;br /&gt;
Lua has &amp;lt;code&amp;gt;break&amp;lt;/code&amp;gt; statement, but no &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt; (use condition inside loop instead). Additionally, Netio Lua implementation limits the loop iterations to 32k.&lt;br /&gt;
&lt;br /&gt;
=== While ===&lt;br /&gt;
While syntax is not different to other languages:&lt;br /&gt;
 local i = 0&lt;br /&gt;
 while i~=3 do&lt;br /&gt;
   i = i + 1&lt;br /&gt;
   logf(&amp;quot;%d&amp;quot;,i)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
=== Repeat until ===&lt;br /&gt;
Repeat until syntax is the same as Pascal's, other languages have similar do-while loops:&lt;br /&gt;
 local i = 0&lt;br /&gt;
 repeat&lt;br /&gt;
   i = i + 1&lt;br /&gt;
   logf(&amp;quot;%d&amp;quot;,i)&lt;br /&gt;
 until i==3&lt;br /&gt;
&lt;br /&gt;
=== Numeric for ===&lt;br /&gt;
Arrays in Lua are one-based (in indices are not specified, the first one is 1, not 0).&lt;br /&gt;
 local arr = {2,3,7,5}&lt;br /&gt;
 for i=1,#arr do logf(&amp;quot;%d&amp;quot;,arr[i]) end&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;b&amp;gt;for&amp;lt;/b&amp;gt; initVar,limit,increment &amp;lt;b&amp;gt;do&amp;lt;/b&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;i&amp;gt;number assignment&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;initVar&amp;lt;/code&amp;gt; inits loop-local variable&lt;br /&gt;
* &amp;lt;i&amp;gt;number&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;limit&amp;lt;/code&amp;gt; loops until initVar reaches this value&lt;br /&gt;
* &amp;lt;i&amp;gt;optional number&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;increment&amp;lt;/code&amp;gt; after each loop initVar increment by this value (default 1)&lt;br /&gt;
&lt;br /&gt;
=== Generic for ===&lt;br /&gt;
Is rather sophisticated. Most common example (the order of elements in &amp;lt;code&amp;gt;pairs()&amp;lt;/code&amp;gt; is not guaranteed):&lt;br /&gt;
 local tab = {one=1, two=2, three=3}&lt;br /&gt;
 for key,val in pairs(tab) do logf(&amp;quot;%s:%d&amp;quot;,key,val) end&lt;br /&gt;
Generic for syntax&lt;br /&gt;
 &amp;lt;b&amp;gt;for&amp;lt;/b&amp;gt; var_1, ..., var_n &amp;lt;b&amp;gt;in&amp;lt;/b&amp;gt; explist &amp;lt;b&amp;gt;do&amp;lt;/b&amp;gt; block end&lt;br /&gt;
is equivalent to (Full explanation [https://www.lua.org/pil/7.2.html here].)&lt;br /&gt;
 do&lt;br /&gt;
   local _f, _s, _var = explist&lt;br /&gt;
   while true do&lt;br /&gt;
     local var_1, ... , var_n = _f(_s, _var)&lt;br /&gt;
     _var = var_1&lt;br /&gt;
     if _var == nil then break end&lt;br /&gt;
     block&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Iterator closure that holds its state&lt;br /&gt;
 function iter(a)&lt;br /&gt;
   local i = 0&lt;br /&gt;
   return function()&lt;br /&gt;
     i = i+1&lt;br /&gt;
     return a[i]&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 local arr = {2,3,7,5}&lt;br /&gt;
 for value in iter(arr) do&lt;br /&gt;
   logf(&amp;quot;%d&amp;quot;,value)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Stateless iterator (in this case returns variable list: key and value)&lt;br /&gt;
 function iter(a,i)&lt;br /&gt;
   i = i+1&lt;br /&gt;
   if a[i] then return i,a[i] end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 local arr = {2,3,7,5}&lt;br /&gt;
 for k,v in iter,arr,0 do&lt;br /&gt;
   logf(&amp;quot;%d:%d&amp;quot;,k,v)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Same effect using &amp;lt;code&amp;gt;ipairs()&amp;lt;/code&amp;gt; Lua function (without initial state)&lt;br /&gt;
 for k,v in ipairs(arr) do&lt;br /&gt;
   logf(&amp;quot;%d:%d&amp;quot;,k,v)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Now return to the most common example above using &amp;lt;code&amp;gt;pairs()&amp;lt;/code&amp;gt; Lua function and read about &amp;lt;code&amp;gt;pairs()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;ipairs()&amp;lt;/code&amp;gt; implementation [https://www.lua.org/pil/7.3.html here].&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
&lt;br /&gt;
Lua allows multiple results (comma separated):&lt;br /&gt;
&lt;br /&gt;
 function diskSpace()&lt;br /&gt;
   return devices.system.freeSpace, devices.system.totalSpace&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 logf(&amp;quot;Free space: %d MB&amp;quot;, diskSpace()) -- only first return value is used&lt;br /&gt;
 local free,total = diskSpace() -- values are stored into LHS var-list&lt;br /&gt;
 logf(&amp;quot;Free space: %d %%&amp;quot;, 100*free/total)&lt;br /&gt;
&lt;br /&gt;
Variable-length arguments are also available:&lt;br /&gt;
&lt;br /&gt;
 function sum(...)&lt;br /&gt;
   local result = 0&lt;br /&gt;
   for _,v in ipairs(arg) do&lt;br /&gt;
     result = result + v&lt;br /&gt;
   end&lt;br /&gt;
   return result&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 logf(&amp;quot;Sum: %d&amp;quot;, sum(2,3,5))&lt;/div&gt;</summary>
		<author><name>Jturon</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=Welcome_to_NETIO_resources_%26_projects_%26_documentation_overview&amp;diff=365</id>
		<title>Welcome to NETIO resources &amp; projects &amp; documentation overview</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=Welcome_to_NETIO_resources_%26_projects_%26_documentation_overview&amp;diff=365"/>
		<updated>2017-05-06T07:46:59Z</updated>

		<summary type="html">&lt;p&gt;Jturon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;div style=&amp;quot;text-align: center; white-space: nowrap;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block; padding: 0 2em; margin-bottom: 2em; width: 40%; min-width: 15em; text-align: justify; vertical-align: top; white-space: normal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;margin-bottom: 0.5em; margin-top: 50px; height: 50px;&amp;quot;&amp;gt;[[Soubor:Netio-mainlogo.png|200px]]&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;h2 style=&amp;quot;background: #005f41; color: #FFF; margin: 0 -1em; padding: 0 1em;&amp;quot;&amp;gt; Introducing NETIO &amp;lt;/h2&amp;gt;&lt;br /&gt;
NETIO sockets can operate just like any socket, but it can be connected as a network node and communicate in many protocols with various devices.&lt;br /&gt;
&lt;br /&gt;
=== NETIO Features ===&lt;br /&gt;
Coming soon.&lt;br /&gt;
&lt;br /&gt;
=== Connect NETIO to your network ===&lt;br /&gt;
Coming soon.&lt;br /&gt;
&lt;br /&gt;
=== NETIO web interface ===&lt;br /&gt;
Coming soon.&lt;br /&gt;
&lt;br /&gt;
=== A simple NETIO application ===&lt;br /&gt;
Coming soon.&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;div style=&amp;quot;display: inline-block; padding: 0 2em; border-left: 1px solid gray; width: 40%; min-width: 15em; text-align: justify; white-space: normal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;margin-bottom: 0.5em; height: 100px&amp;quot;&amp;gt;[[Soubor:Netio-lua.png]]&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;h2 style=&amp;quot;background: #005f41; color: #FFF; margin: 0 -1em; padding: 0 1em;&amp;quot;&amp;gt; NETIO Programming &amp;lt;/h2&amp;gt;&lt;br /&gt;
NETIO uses Lua as its scripting language. To master it, follow these references:&lt;br /&gt;
&lt;br /&gt;
=== [https://www.lua.org/pil/contents.html Lua tutorial] ===&lt;br /&gt;
If you are new to Lua and programming as such and if you are eager to learn, this is your starting point. Before you proceed to NETIO Sockets, this [https://www.lua.org/demo.html online environment] will be a good place to test your first scripts.&lt;br /&gt;
&lt;br /&gt;
=== [[NETIO Lua Manual]] ===&lt;br /&gt;
A quick jump into NETIO Lua programming if you mastered another programming language. If you already know Lua, just keep in mind that NETIO Lua loops are limited to 32k cycles and all numbers are integers, not decimals like in standard Lua.&lt;br /&gt;
&lt;br /&gt;
=== [[NETIO Lua Reference]] ===&lt;br /&gt;
If you can already code in Lua, NETIO-specific Lua functions is your main guide to programm NETIO Sockets.&lt;br /&gt;
&lt;br /&gt;
=== [https://www.lua.org/manual/5.3/ Lua manual] ===&lt;br /&gt;
Although you won't need everything mentioned here, it is worth to peek here from time to time to grasp the concepts of effective Lua programming.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;/div&gt;</summary>
		<author><name>Jturon</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=File:Netio-lua.png&amp;diff=364</id>
		<title>File:Netio-lua.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=File:Netio-lua.png&amp;diff=364"/>
		<updated>2017-05-06T07:38:02Z</updated>

		<summary type="html">&lt;p&gt;Jturon: Jturon načetl novou verzi Soubor:Netio-lua.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Jturon</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=File:Netio-mainlogo.png&amp;diff=363</id>
		<title>File:Netio-mainlogo.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=File:Netio-mainlogo.png&amp;diff=363"/>
		<updated>2017-05-06T07:37:22Z</updated>

		<summary type="html">&lt;p&gt;Jturon: Jturon načetl novou verzi Soubor:Netio-mainlogo.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Jturon</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=File:Netio-mainlogo.png&amp;diff=362</id>
		<title>File:Netio-mainlogo.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=File:Netio-mainlogo.png&amp;diff=362"/>
		<updated>2017-05-06T07:34:33Z</updated>

		<summary type="html">&lt;p&gt;Jturon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Jturon</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=File:Netio-lua.png&amp;diff=358</id>
		<title>File:Netio-lua.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=File:Netio-lua.png&amp;diff=358"/>
		<updated>2017-05-06T07:24:23Z</updated>

		<summary type="html">&lt;p&gt;Jturon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Jturon</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=Welcome_to_NETIO_resources_%26_projects_%26_documentation_overview&amp;diff=356</id>
		<title>Welcome to NETIO resources &amp; projects &amp; documentation overview</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=Welcome_to_NETIO_resources_%26_projects_%26_documentation_overview&amp;diff=356"/>
		<updated>2017-05-06T07:14:44Z</updated>

		<summary type="html">&lt;p&gt;Jturon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;div style=&amp;quot;text-align: center&amp;quot;&amp;gt;[[Soubor:Netio-logo.png]]&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;text-align: center; white-space: nowrap;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block; padding: 0 2em; margin-bottom: 2em; width: 40%; min-width: 15em; text-align: justify; vertical-align: top; white-space: normal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;h2 style=&amp;quot;background: #005f41; color: #FFF; margin: 0 -1em; padding: 0 1em;&amp;quot;&amp;gt; Introducing NETIO &amp;lt;/h2&amp;gt;&lt;br /&gt;
NETIO sockets can operate just like any socket, but it can be connected as a network node and communicate in many protocols with various devices.&lt;br /&gt;
&lt;br /&gt;
=== NETIO Features ===&lt;br /&gt;
Coming soon.&lt;br /&gt;
&lt;br /&gt;
=== Connect NETIO to your network ===&lt;br /&gt;
Coming soon.&lt;br /&gt;
&lt;br /&gt;
=== NETIO web interface ===&lt;br /&gt;
Coming soon.&lt;br /&gt;
&lt;br /&gt;
=== A simple NETIO application ===&lt;br /&gt;
Coming soon.&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;div style=&amp;quot;display: inline-block; padding: 0 2em; border-left: 1px solid gray; width: 40%; min-width: 15em; text-align: justify; white-space: normal;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;h2 style=&amp;quot;background: #005f41; color: #FFF; margin: 0 -1em; padding: 0 1em;&amp;quot;&amp;gt; NETIO Programming &amp;lt;/h2&amp;gt;&lt;br /&gt;
NETIO uses Lua as its scripting language. To master it, follow these references:&lt;br /&gt;
&lt;br /&gt;
=== [https://www.lua.org/pil/contents.html Lua tutorial] ===&lt;br /&gt;
If you are new to Lua and programming as such and if you are eager to learn, this is your starting point. Before you proceed to NETIO Sockets, this [https://www.lua.org/demo.html online environment] will be a good place to test your first scripts.&lt;br /&gt;
&lt;br /&gt;
=== [[NETIO Lua Manual]] ===&lt;br /&gt;
A quick jump into NETIO Lua programming if you mastered another programming language. If you already know Lua, just keep in mind that NETIO Lua loops are limited to 32k cycles and all numbers are integers, not decimals like in standard Lua.&lt;br /&gt;
&lt;br /&gt;
=== [[NETIO Lua Reference]] ===&lt;br /&gt;
If you can already code in Lua, NETIO-specific Lua functions is your main guide to programm NETIO Sockets.&lt;br /&gt;
&lt;br /&gt;
=== [https://www.lua.org/manual/5.3/ Lua manual] ===&lt;br /&gt;
Although you won't need everything mentioned here, it is worth to peek here from time to time to grasp the concepts of effective Lua programming.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;/div&gt;</summary>
		<author><name>Jturon</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=Welcome_to_NETIO_resources_%26_projects_%26_documentation_overview&amp;diff=355</id>
		<title>Welcome to NETIO resources &amp; projects &amp; documentation overview</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=Welcome_to_NETIO_resources_%26_projects_%26_documentation_overview&amp;diff=355"/>
		<updated>2017-05-06T07:14:08Z</updated>

		<summary type="html">&lt;p&gt;Jturon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;div style=&amp;quot;text-align: center&amp;quot;&amp;gt;[[Soubor:Netio-logo.png]]&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;text-align: center; white-space: nowrap;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block; padding: 0 2em; margin-bottom: 2em; width: 40%; min-width: 15em; text-align: justify; vertical-align: top;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;h2 style=&amp;quot;background: #005f41; color: #FFF; margin: 0 -1em; padding: 0 1em;&amp;quot;&amp;gt; Introducing NETIO &amp;lt;/h2&amp;gt;&lt;br /&gt;
NETIO sockets can operate just like any socket, but it can be connected as a network node and communicate in many protocols with various devices.&lt;br /&gt;
&lt;br /&gt;
=== NETIO Features ===&lt;br /&gt;
Coming soon.&lt;br /&gt;
&lt;br /&gt;
=== Connect NETIO to your network ===&lt;br /&gt;
Coming soon.&lt;br /&gt;
&lt;br /&gt;
=== NETIO web interface ===&lt;br /&gt;
Coming soon.&lt;br /&gt;
&lt;br /&gt;
=== A simple NETIO application ===&lt;br /&gt;
Coming soon.&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;div style=&amp;quot;display: inline-block; padding: 0 2em; border-left: 1px solid gray; width: 40%; min-width: 15em; text-align: justify;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;h2 style=&amp;quot;background: #005f41; color: #FFF; margin: 0 -1em; padding: 0 1em;&amp;quot;&amp;gt; NETIO Programming &amp;lt;/h2&amp;gt;&lt;br /&gt;
NETIO uses Lua as its scripting language. To master it, follow these references:&lt;br /&gt;
&lt;br /&gt;
=== [https://www.lua.org/pil/contents.html Lua tutorial] ===&lt;br /&gt;
If you are new to Lua and programming as such and if you are eager to learn, this is your starting point. Before you proceed to NETIO Sockets, this [https://www.lua.org/demo.html online environment] will be a good place to test your first scripts.&lt;br /&gt;
&lt;br /&gt;
=== [[NETIO Lua Manual]] ===&lt;br /&gt;
A quick jump into NETIO Lua programming if you mastered another programming language. If you already know Lua, just keep in mind that NETIO Lua loops are limited to 32k cycles and all numbers are integers, not decimals like in standard Lua.&lt;br /&gt;
&lt;br /&gt;
=== [[NETIO Lua Reference]] ===&lt;br /&gt;
If you can already code in Lua, NETIO-specific Lua functions is your main guide to programm NETIO Sockets.&lt;br /&gt;
&lt;br /&gt;
=== [https://www.lua.org/manual/5.3/ Lua manual] ===&lt;br /&gt;
Although you won't need everything mentioned here, it is worth to peek here from time to time to grasp the concepts of effective Lua programming.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;/div&gt;</summary>
		<author><name>Jturon</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=Welcome_to_NETIO_resources_%26_projects_%26_documentation_overview&amp;diff=354</id>
		<title>Welcome to NETIO resources &amp; projects &amp; documentation overview</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=Welcome_to_NETIO_resources_%26_projects_%26_documentation_overview&amp;diff=354"/>
		<updated>2017-05-06T07:11:38Z</updated>

		<summary type="html">&lt;p&gt;Jturon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;div style=&amp;quot;text-align: center&amp;quot;&amp;gt;[[Soubor:Netio-logo.png]]&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;text-align: center&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block; padding: 0 2em; margin-bottom: 2em; width: 40%; min-width: 15em; text-align: justify; vertical-align: top;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;h2 style=&amp;quot;background: #005f41; color: #FFF; margin: 0 -1em; padding: 0 1em;&amp;quot;&amp;gt; Introducing NETIO &amp;lt;/h2&amp;gt;&lt;br /&gt;
NETIO sockets can operate just like any socket, but it can be connected as a network node and communicate in many protocols with various devices.&lt;br /&gt;
&lt;br /&gt;
=== NETIO Features ===&lt;br /&gt;
Coming soon.&lt;br /&gt;
&lt;br /&gt;
=== Connect NETIO to your network ===&lt;br /&gt;
Coming soon.&lt;br /&gt;
&lt;br /&gt;
=== NETIO web interface ===&lt;br /&gt;
Coming soon.&lt;br /&gt;
&lt;br /&gt;
=== A simple NETIO application ===&lt;br /&gt;
Coming soon.&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;div style=&amp;quot;display: inline-block; padding: 0 2em; border-left: 1px solid gray; width: 40%; min-width: 15em; text-align: justify;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;h2 style=&amp;quot;background: #005f41; color: #FFF; margin: 0 -1em; padding: 0 1em;&amp;quot;&amp;gt; NETIO Programming &amp;lt;/h2&amp;gt;&lt;br /&gt;
NETIO uses Lua as its scripting language. To master it, follow these references:&lt;br /&gt;
&lt;br /&gt;
=== [https://www.lua.org/pil/contents.html Lua tutorial] ===&lt;br /&gt;
If you are new to Lua and programming as such and if you are eager to learn, this is your starting point. Before you proceed to NETIO Sockets, this [https://www.lua.org/demo.html online environment] will be a good place to test your first scripts.&lt;br /&gt;
&lt;br /&gt;
=== [[NETIO Lua Manual]] ===&lt;br /&gt;
A quick jump into NETIO Lua programming if you mastered another programming language. If you already know Lua, just keep in mind that NETIO Lua loops are limited to 32k cycles and all numbers are integers, not decimals like in standard Lua.&lt;br /&gt;
&lt;br /&gt;
=== [[NETIO Lua Reference]] ===&lt;br /&gt;
If you can already code in Lua, NETIO-specific Lua functions is your main guide to programm NETIO Sockets.&lt;br /&gt;
&lt;br /&gt;
=== [https://www.lua.org/manual/5.3/ Lua manual] ===&lt;br /&gt;
Although you won't need everything mentioned here, it is worth to peek here from time to time to grasp the concepts of effective Lua programming.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;/div&gt;</summary>
		<author><name>Jturon</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=Welcome_to_NETIO_resources_%26_projects_%26_documentation_overview&amp;diff=353</id>
		<title>Welcome to NETIO resources &amp; projects &amp; documentation overview</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=Welcome_to_NETIO_resources_%26_projects_%26_documentation_overview&amp;diff=353"/>
		<updated>2017-05-06T07:09:53Z</updated>

		<summary type="html">&lt;p&gt;Jturon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;div style=&amp;quot;text-align: center&amp;quot;&amp;gt;[[Soubor:Netio-logo.png]]&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;text-align: center&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block; padding: 0 2em; margin-bottom: 2em; width: 40%; min-width: 15em; text-align: justify; vertical-align: top;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;h2 style=&amp;quot;background: #005f41; color: #FFF; margin: 0 -1em; padding: 0 1em;&amp;quot;&amp;gt; Introducing NETIO &amp;lt;/h2&amp;gt;&lt;br /&gt;
NETIO sockets can operate just like any socket, but it can be connected as a network node and communicate in many protocols with various devices.&lt;br /&gt;
&lt;br /&gt;
=== NETIO Features ===&lt;br /&gt;
Coming soon.&lt;br /&gt;
&lt;br /&gt;
=== Connect NETIO to your network ===&lt;br /&gt;
Coming soon.&lt;br /&gt;
&lt;br /&gt;
=== NETIO web interface ===&lt;br /&gt;
Coming soon.&lt;br /&gt;
&lt;br /&gt;
=== A simple NETIO application ===&lt;br /&gt;
Coming soon.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;display: inline-block; padding: 0 2em; border-left: 1px solid gray; width: 40%; min-width: 15em; text-align: justify;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;h2 style=&amp;quot;background: #005f41; color: #FFF; margin: 0 -1em; padding: 0 1em;&amp;quot;&amp;gt; NETIO Programming &amp;lt;/h2&amp;gt;&lt;br /&gt;
NETIO uses Lua as its scripting language. To master it, follow these references:&lt;br /&gt;
&lt;br /&gt;
=== [https://www.lua.org/pil/contents.html Lua tutorial] ===&lt;br /&gt;
If you are new to Lua and programming as such and if you are eager to learn, this is your starting point. Before you proceed to NETIO Sockets, this [https://www.lua.org/demo.html online environment] will be a good place to test your first scripts.&lt;br /&gt;
&lt;br /&gt;
=== [[NETIO Lua Manual]] ===&lt;br /&gt;
A quick jump into NETIO Lua programming if you mastered another programming language. If you already know Lua, just keep in mind that NETIO Lua loops are limited to 32k cycles and all numbers are integers, not decimals like in standard Lua.&lt;br /&gt;
&lt;br /&gt;
=== [[NETIO Lua Reference]] ===&lt;br /&gt;
If you can already code in Lua, NETIO-specific Lua functions is your main guide to programm NETIO Sockets.&lt;br /&gt;
&lt;br /&gt;
=== [https://www.lua.org/manual/5.3/ Lua manual] ===&lt;br /&gt;
Although you won't need everything mentioned here, it is worth to peek here from time to time to grasp the concepts of effective Lua programming.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;/div&gt;</summary>
		<author><name>Jturon</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=Welcome_to_NETIO_resources_%26_projects_%26_documentation_overview&amp;diff=351</id>
		<title>Welcome to NETIO resources &amp; projects &amp; documentation overview</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=Welcome_to_NETIO_resources_%26_projects_%26_documentation_overview&amp;diff=351"/>
		<updated>2017-05-05T19:02:07Z</updated>

		<summary type="html">&lt;p&gt;Jturon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;center&amp;gt;[[Soubor:Netio-logo.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;inline-block; float: left; padding: 0 2em; width: 40%; min-width: 15em; text-align: justify;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;h2 style=&amp;quot;background: #005f41; color: #FFF; margin: 0 -1em; padding: 0 1em;&amp;quot;&amp;gt; Introducing NETIO &amp;lt;/h2&amp;gt;&lt;br /&gt;
NETIO sockets can operate just like any socket, but it can be connected as a network node and communicate in many protocols with various devices.&lt;br /&gt;
&lt;br /&gt;
=== NETIO Features ===&lt;br /&gt;
Coming soon.&lt;br /&gt;
&lt;br /&gt;
=== Connect NETIO to your network ===&lt;br /&gt;
Coming soon.&lt;br /&gt;
&lt;br /&gt;
=== NETIO web interface ===&lt;br /&gt;
Coming soon.&lt;br /&gt;
&lt;br /&gt;
=== A simple NETIO application ===&lt;br /&gt;
Coming soon.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;inline-block; float: left; padding: 0 2em; border-left: 1px solid gray; width: 40%; min-width: 15em; text-align: justify;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;h2 style=&amp;quot;background: #005f41; color: #FFF; margin: 0 -1em; padding: 0 1em;&amp;quot;&amp;gt; NETIO Programming &amp;lt;/h2&amp;gt;&lt;br /&gt;
NETIO uses Lua as its scripting language. To master it, follow these references:&lt;br /&gt;
&lt;br /&gt;
=== [https://www.lua.org/pil/contents.html Lua tutorial] ===&lt;br /&gt;
If you are new to Lua and programming as such and if you are eager to learn, this is your starting point. Before you proceed to NETIO Sockets, this [https://www.lua.org/demo.html online environment] will be a good place to test your first scripts.&lt;br /&gt;
&lt;br /&gt;
=== [[NETIO Lua Manual]] ===&lt;br /&gt;
A quick jump into NETIO Lua programming if you mastered another programming language. If you already know Lua, just keep in mind that NETIO Lua loops are limited to 32k cycles and all numbers are integers, not decimals like in standard Lua.&lt;br /&gt;
&lt;br /&gt;
=== [[NETIO Lua Reference]] ===&lt;br /&gt;
If you can already code in Lua, NETIO-specific Lua functions is your main guide to programm NETIO Sockets.&lt;br /&gt;
&lt;br /&gt;
=== [https://www.lua.org/manual/5.3/ Lua manual] ===&lt;br /&gt;
Although you won't need everything mentioned here, it is worth to peek here from time to time to grasp the concepts of effective Lua programming.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;/div&gt;</summary>
		<author><name>Jturon</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=Welcome_to_NETIO_resources_%26_projects_%26_documentation_overview&amp;diff=350</id>
		<title>Welcome to NETIO resources &amp; projects &amp; documentation overview</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=Welcome_to_NETIO_resources_%26_projects_%26_documentation_overview&amp;diff=350"/>
		<updated>2017-05-05T19:01:33Z</updated>

		<summary type="html">&lt;p&gt;Jturon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;center&amp;gt;[[Soubor:Netio-logo.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;inline-block; float: left; padding: 0 2em; width: 40%; min-width: 15em; text-align: justify;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;h2 style=&amp;quot;background: #005f41; color: #FFF; margin: 0 -1em; padding: 0 1em;&amp;quot;&amp;gt; Introducing NETIO &amp;lt;/h2&amp;gt;&lt;br /&gt;
NETIO sockets can operate just like any socket, but it can be connected as a network node and communicate in many protocols with various devices.&lt;br /&gt;
&lt;br /&gt;
=== NETIO Features ===&lt;br /&gt;
Coming soon.&lt;br /&gt;
&lt;br /&gt;
=== Connect NETIO to your network ===&lt;br /&gt;
Coming soon.&lt;br /&gt;
&lt;br /&gt;
=== NETIO web interface ===&lt;br /&gt;
Coming soon.&lt;br /&gt;
&lt;br /&gt;
=== Programming simple NETIO application ===&lt;br /&gt;
Coming soon.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;inline-block; float: left; padding: 0 2em; border-left: 1px solid gray; width: 40%; min-width: 15em; text-align: justify;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;h2 style=&amp;quot;background: #005f41; color: #FFF; margin: 0 -1em; padding: 0 1em;&amp;quot;&amp;gt; NETIO Programming &amp;lt;/h2&amp;gt;&lt;br /&gt;
NETIO uses Lua as its scripting language. To master it, follow these references:&lt;br /&gt;
&lt;br /&gt;
=== [https://www.lua.org/pil/contents.html Lua tutorial] ===&lt;br /&gt;
If you are new to Lua and programming as such and if you are eager to learn, this is your starting point. Before you proceed to NETIO Sockets, this [https://www.lua.org/demo.html online environment] will be a good place to test your first scripts.&lt;br /&gt;
&lt;br /&gt;
=== [[NETIO Lua Manual]] ===&lt;br /&gt;
A quick jump into NETIO Lua programming if you mastered another programming language. If you already know Lua, just keep in mind that NETIO Lua loops are limited to 32k cycles and all numbers are integers, not decimals like in standard Lua.&lt;br /&gt;
&lt;br /&gt;
=== [[NETIO Lua Reference]] ===&lt;br /&gt;
If you can already code in Lua, NETIO-specific Lua functions is your main guide to programm NETIO Sockets.&lt;br /&gt;
&lt;br /&gt;
=== [https://www.lua.org/manual/5.3/ Lua manual] ===&lt;br /&gt;
Although you won't need everything mentioned here, it is worth to peek here from time to time to grasp the concepts of effective Lua programming.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;/div&gt;</summary>
		<author><name>Jturon</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=NETIO_Lua_Reference&amp;diff=348</id>
		<title>NETIO Lua Reference</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=NETIO_Lua_Reference&amp;diff=348"/>
		<updated>2017-05-05T18:24:36Z</updated>

		<summary type="html">&lt;p&gt;Jturon: Jturon přesunul stránku Netio Lua Reference na NETIO Lua Reference&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Outlet Management ==&lt;br /&gt;
&amp;lt;big&amp;gt;&amp;lt;b&amp;gt; devices.system &amp;lt;/b&amp;gt;&amp;lt;/big&amp;gt;&lt;br /&gt;
* function [[Function devices.system.SetOut()|.SetOut()]] - turns the outlet on or off&lt;br /&gt;
* function [[Function devices.system.ResetOut()|.ResetOut()]] - turns the outlet off and then resets its previous state&lt;br /&gt;
* string [[String devices.system.output1_state|.output1_state]] - outlet's state&lt;br /&gt;
* number [[Number devices.system.output1_consumption|.output1_consumption]] - outlet's consumption (in Watts)&lt;br /&gt;
* number [[Number devices.system.output1_cumulatedConsumption|.output1_cumulatedConsumption]] - outlet's consumed energy (in Watthours)&lt;br /&gt;
* function [[Function devices.system.resetCumulativeConsumption()|.resetCumulativeConsumption()]] - resets outlet's energy counter&lt;br /&gt;
* string [[String devices.system.output1_consumptionStart|.output1_consumptionStart]] - date and time since the last energy counter reset&lt;br /&gt;
&lt;br /&gt;
== Socket System Management ==&lt;br /&gt;
&amp;lt;big&amp;gt;&amp;lt;b&amp;gt; devices.system&amp;lt;/b&amp;gt; &amp;lt;/big&amp;gt;&lt;br /&gt;
* number [[number devices.system.averageLoad|.averageLoad]] - socket's CPU load&lt;br /&gt;
* function [[Function devices.system.Reboot()|.Reboot()]] - reboot socket's system&lt;br /&gt;
* number [[Number devices.system.sessionCount|.sessionCount]] - number of connected users&lt;br /&gt;
* number [[Number devices.system.freeSpace|.freeSpace]] - free disk space&lt;br /&gt;
* number [[Number devices.system.totalSpace|.totalSpace]] - total disk space&lt;br /&gt;
&lt;br /&gt;
== Socket Communication ==&lt;br /&gt;
* function [[Function ping()|ping()]] - tests socket's network responsivity&lt;br /&gt;
* function [[Function mail()|mail()]] - sends e-mail&lt;br /&gt;
* function [[Function devices.system.CustomCGI()|devices.system.CustomCGI()]] - send HTTP request&lt;br /&gt;
* function [[Function cgiGet()|cgiGet()]] &amp;lt;sup&amp;gt;&amp;lt;code&amp;gt;2.3.5&amp;lt;/code&amp;gt;&amp;lt;/sup&amp;gt; - send HTTP request and receive response&lt;br /&gt;
* table [[Table event.args|event.args]] - HTTP GET /event variables table&lt;br /&gt;
&lt;br /&gt;
== XML Processing &amp;lt;sup&amp;gt;&amp;lt;code&amp;gt;2.3.6&amp;lt;/code&amp;gt;&amp;lt;/sup&amp;gt; ==&lt;br /&gt;
&amp;lt;big&amp;gt;&amp;lt;b&amp;gt;xml&amp;lt;/b&amp;gt;&amp;lt;/big&amp;gt;&lt;br /&gt;
* function [[Function xml.escape()|.escape()]] - escapes XML string to fit xml node contents&lt;br /&gt;
* function [[Function xml.check()|.check()]] - tests if string is well-formed XML&lt;br /&gt;
* function [[Function xml.parse()|.parse()]] - parses XML string into [[Function xml.parse()#XmlElement|XmlElement]] object&lt;br /&gt;
&lt;br /&gt;
== Standard Lua Functions ==&lt;br /&gt;
* function [https://www.lua.org/pil/8.3.html assert(), error()] issues an error&lt;br /&gt;
* function [https://www.lua.org/pil/7.3.html ipairs(), pairs(), next()] traverse tables&lt;br /&gt;
* function [https://www.lua.org/pil/2.4.html tonumber(), tostring()] data type conversion&lt;br /&gt;
* function [https://www.lua.org/pil/8.4.html pcall()] protected call function (handles error inside the function)&lt;br /&gt;
* function [https://www.lua.org/pil/5.2.html select()] selects from multiple return value&lt;br /&gt;
* function [https://www.lua.org/pil/2.html unpack] converts table into multiple values&lt;br /&gt;
* function [https://www.lua.org/pil/2.html type()] returns variable type&lt;br /&gt;
* function [https://www.lua.org/pil/22.1.html os.date(), os.time()] system date and time&lt;br /&gt;
* function os.difftime() returns time span between two times&lt;br /&gt;
&lt;br /&gt;
== Miscellaneous ==&lt;br /&gt;
* function [[Function log()|log()]] - insert a record to the socket's event log&lt;br /&gt;
* function [[Function logf()|logf()]] - insert a formated record (incl. numbers) to the socket's event log&lt;br /&gt;
* function [[Function delay()|delay()]] - execute function with delay (seconds)&lt;br /&gt;
* function [[Function milliDelay()|milliDelay()]] - execute function with delay (milliseconds)&lt;br /&gt;
* function [[Function toboolean()|toboolean()]] - converts any variable to boolean type&lt;/div&gt;</summary>
		<author><name>Jturon</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=Netio_Lua_Reference&amp;diff=349</id>
		<title>Netio Lua Reference</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=Netio_Lua_Reference&amp;diff=349"/>
		<updated>2017-05-05T18:24:36Z</updated>

		<summary type="html">&lt;p&gt;Jturon: Jturon přesunul stránku Netio Lua Reference na NETIO Lua Reference&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#PŘESMĚRUJ [[NETIO Lua Reference]]&lt;/div&gt;</summary>
		<author><name>Jturon</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=NETIO_Lua_Manual&amp;diff=346</id>
		<title>NETIO Lua Manual</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=NETIO_Lua_Manual&amp;diff=346"/>
		<updated>2017-05-05T18:24:03Z</updated>

		<summary type="html">&lt;p&gt;Jturon: Jturon přesunul stránku Netio Lua Manual na NETIO Lua Manual&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Debugging ==&lt;br /&gt;
To debug your code, use [[Function log()|log()]] and [[Function logf()|logf()]] functions. See the output in system events log.&lt;br /&gt;
&lt;br /&gt;
== Data types ==&lt;br /&gt;
Lua supports these data types:&lt;br /&gt;
* &amp;lt;i&amp;gt;nil&amp;lt;/i&amp;gt; (to assign &amp;lt;i&amp;gt;nil&amp;lt;/i&amp;gt; value effectively deletes the variable)&lt;br /&gt;
* &amp;lt;i&amp;gt;boolean&amp;lt;/i&amp;gt; (falsy values are &amp;lt;i&amp;gt;nil&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;false&amp;lt;/i&amp;gt; only; &amp;quot;&amp;quot; and 0 evaluates as &amp;lt;i&amp;gt;true&amp;lt;/i&amp;gt;)&lt;br /&gt;
* &amp;lt;i&amp;gt;number&amp;lt;/i&amp;gt; (decimals only in standard Lua, integers only in Netio Lua)&lt;br /&gt;
* &amp;lt;i&amp;gt;string&amp;lt;/i&amp;gt; (same strings share same address, so equality operator measures both address and value)&lt;br /&gt;
* &amp;lt;i&amp;gt;tables&amp;lt;/i&amp;gt; are associative arrays. (Tables with numeric indices are, well, just arrays.)&lt;br /&gt;
&lt;br /&gt;
 local numbers = {2,3,7,5} -- array (first index = 1)&lt;br /&gt;
 local dictionary = {one=1, two=2, three=3} -- table&lt;br /&gt;
 local numbersZeroBased = {[0]=2,3,7,5} -- array (first index = 0)&lt;br /&gt;
&lt;br /&gt;
== Operators ==&lt;br /&gt;
Lua has its own manners:&lt;br /&gt;
* &amp;lt;code&amp;gt;~=&amp;lt;/code&amp;gt; is inequality operator&lt;br /&gt;
* &amp;lt;code&amp;gt;..&amp;lt;/code&amp;gt; is string concatenation (don't use plus)&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;s&amp;gt;i++&amp;lt;/s&amp;gt;&amp;lt;/code&amp;gt; no increment/decrement operator &amp;lt;code&amp;gt;i = i + 1&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;s&amp;gt;max = a&amp;lt;b ? b : a&amp;lt;/s&amp;gt;&amp;lt;/code&amp;gt; no ternary operator. Use (and get used to) &amp;lt;i&amp;gt;and idiom&amp;lt;/i&amp;gt; instead: &amp;lt;code&amp;gt;max = (a&amp;lt;b) and b or a&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;i&amp;gt;or idiom&amp;lt;/i&amp;gt; works: &amp;lt;code&amp;gt;x = x or 42&amp;lt;/code&amp;gt; is equivalent to &amp;lt;code&amp;gt;if not x then x = 42 end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Conditions ==&lt;br /&gt;
Lua conditions has casual syntax, see [https://www.lua.org/pil/4.3.1.html here]. Just keep in mind to merge &amp;lt;code&amp;gt;else&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;elseif&amp;lt;/code&amp;gt; or multiple &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt;s are required.&lt;br /&gt;
&lt;br /&gt;
Note that falsy values are &amp;lt;i&amp;gt;nil&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;false&amp;lt;/i&amp;gt; only. Empty string and 0 evaluates as true. If you come from C, you might be surprised by following snippet:&lt;br /&gt;
&lt;br /&gt;
 if devices.system.output1_consumption then&lt;br /&gt;
   -- always happens, even if the consumption is 0&lt;br /&gt;
   log(&amp;quot;Outlet 1 supplies power&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 if not devices.system.output1_consumption then&lt;br /&gt;
   -- never happens, even if the consumption is 0&lt;br /&gt;
   log(&amp;quot;Outlet 1 is idle&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
== Loops ==&lt;br /&gt;
Lua has &amp;lt;code&amp;gt;break&amp;lt;/code&amp;gt; statement, but no &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt; (use condition inside loop instead). Additionally, Netio Lua implementation limits the loop iterations to 32k.&lt;br /&gt;
&lt;br /&gt;
=== While ===&lt;br /&gt;
While syntax is not different to other languages:&lt;br /&gt;
 local i = 0&lt;br /&gt;
 while i~=3 do&lt;br /&gt;
   i = i + 1&lt;br /&gt;
   logf(&amp;quot;%d&amp;quot;,i)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
=== Repeat until ===&lt;br /&gt;
Repeat until syntax is the same as Pascal's, other languages have similar do-while loops:&lt;br /&gt;
 local i = 0&lt;br /&gt;
 repeat&lt;br /&gt;
   i = i + 1&lt;br /&gt;
   logf(&amp;quot;%d&amp;quot;,i)&lt;br /&gt;
 until i==3&lt;br /&gt;
&lt;br /&gt;
=== Numeric for ===&lt;br /&gt;
Arrays in Lua are one-based (in indices are not specified, the first one is 1, not 0).&lt;br /&gt;
 local arr = {2,3,7,5}&lt;br /&gt;
 for i=1,#arr do logf(&amp;quot;%d&amp;quot;,arr[i]) end&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;b&amp;gt;for&amp;lt;/b&amp;gt; initVar,limit,increment &amp;lt;b&amp;gt;do&amp;lt;/b&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;i&amp;gt;number assignment&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;initVar&amp;lt;/code&amp;gt; inits loop-local variable&lt;br /&gt;
* &amp;lt;i&amp;gt;number&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;limit&amp;lt;/code&amp;gt; loops until initVar reaches this value&lt;br /&gt;
* &amp;lt;i&amp;gt;optional number&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;increment&amp;lt;/code&amp;gt; after each loop initVar increment by this value (default 1)&lt;br /&gt;
&lt;br /&gt;
=== Generic for ===&lt;br /&gt;
Is rather sophisticated. Most common example (the order of elements in &amp;lt;code&amp;gt;pairs()&amp;lt;/code&amp;gt; is not guaranteed):&lt;br /&gt;
 local tab = {one=1, two=2, three=3}&lt;br /&gt;
 for key,val in pairs(tab) do logf(&amp;quot;%s:%d&amp;quot;,key,val) end&lt;br /&gt;
Generic for syntax&lt;br /&gt;
 &amp;lt;b&amp;gt;for&amp;lt;/b&amp;gt; var_1, ..., var_n &amp;lt;b&amp;gt;in&amp;lt;/b&amp;gt; explist &amp;lt;b&amp;gt;do&amp;lt;/b&amp;gt; block end&lt;br /&gt;
is equivalent to (Full explanation [https://www.lua.org/pil/7.2.html here].)&lt;br /&gt;
 do&lt;br /&gt;
   local _f, _s, _var = explist&lt;br /&gt;
   while true do&lt;br /&gt;
     local var_1, ... , var_n = _f(_s, _var)&lt;br /&gt;
     _var = var_1&lt;br /&gt;
     if _var == nil then break end&lt;br /&gt;
     block&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Iterator closure that holds its state&lt;br /&gt;
 function iter(a)&lt;br /&gt;
   local i = 0&lt;br /&gt;
   return function()&lt;br /&gt;
     i = i+1&lt;br /&gt;
     return a[i]&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 local arr = {2,3,7,5}&lt;br /&gt;
 for value in iter(arr) do&lt;br /&gt;
   logf(&amp;quot;%d&amp;quot;,value)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Stateless iterator (in this case returns variable list: key and value)&lt;br /&gt;
 function iter(a,i)&lt;br /&gt;
   i = i+1&lt;br /&gt;
   if a[i] then return i,a[i] end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 local arr = {2,3,7,5}&lt;br /&gt;
 for k,v in iter,arr,0 do&lt;br /&gt;
   logf(&amp;quot;%d:%d&amp;quot;,k,v)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Same effect using &amp;lt;code&amp;gt;ipairs()&amp;lt;/code&amp;gt; Lua function (without initial state)&lt;br /&gt;
 for k,v in ipairs(arr) do&lt;br /&gt;
   logf(&amp;quot;%d:%d&amp;quot;,k,v)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Now return to the most common example above using &amp;lt;code&amp;gt;pairs()&amp;lt;/code&amp;gt; Lua function and read about &amp;lt;code&amp;gt;pairs()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;ipairs()&amp;lt;/code&amp;gt; implementation [https://www.lua.org/pil/7.3.html here].&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
&lt;br /&gt;
Lua allows multiple results (comma separated):&lt;br /&gt;
&lt;br /&gt;
 function diskSpace()&lt;br /&gt;
   return devices.system.freeSpace, devices.system.totalSpace&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 logf(&amp;quot;Free space: %d MB&amp;quot;, diskSpace()) -- only first return value is used&lt;br /&gt;
 local free,total = diskSpace() -- values are stored into LHS var-list&lt;br /&gt;
 logf(&amp;quot;Free space: %d %%&amp;quot;, 100*free/total)&lt;br /&gt;
&lt;br /&gt;
Variable-length arguments are also available:&lt;br /&gt;
&lt;br /&gt;
 function sum(...)&lt;br /&gt;
   local result = 0&lt;br /&gt;
   for _,v in ipairs(arg) do&lt;br /&gt;
     result = result + v&lt;br /&gt;
   end&lt;br /&gt;
   return result&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 logf(&amp;quot;Sum: %d&amp;quot;, sum(2,3,5))&lt;/div&gt;</summary>
		<author><name>Jturon</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=Netio_Lua_Manual&amp;diff=347</id>
		<title>Netio Lua Manual</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=Netio_Lua_Manual&amp;diff=347"/>
		<updated>2017-05-05T18:24:03Z</updated>

		<summary type="html">&lt;p&gt;Jturon: Jturon přesunul stránku Netio Lua Manual na NETIO Lua Manual&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#PŘESMĚRUJ [[NETIO Lua Manual]]&lt;/div&gt;</summary>
		<author><name>Jturon</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=Welcome_to_NETIO_resources_%26_projects_%26_documentation_overview&amp;diff=345</id>
		<title>Welcome to NETIO resources &amp; projects &amp; documentation overview</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=Welcome_to_NETIO_resources_%26_projects_%26_documentation_overview&amp;diff=345"/>
		<updated>2017-05-05T18:23:13Z</updated>

		<summary type="html">&lt;p&gt;Jturon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;center&amp;gt;[[Soubor:Netio-logo.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;inline-block; float: left; padding: 0 2em; width: 40%; min-width: 15em; text-align: justify;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;h2 style=&amp;quot;background: #005f41; color: #FFF; margin: 0 -1em; padding: 0 1em;&amp;quot;&amp;gt; Introducing NETIO &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;inline-block; float: left; padding: 0 2em; border-left: 1px solid gray; width: 40%; min-width: 15em; text-align: justify;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;h2 style=&amp;quot;background: #005f41; color: #FFF; margin: 0 -1em; padding: 0 1em;&amp;quot;&amp;gt; NETIO Programming &amp;lt;/h2&amp;gt;&lt;br /&gt;
NETIO uses Lua as its scripting language. To master it, follow these references:&lt;br /&gt;
&lt;br /&gt;
=== [https://www.lua.org/pil/contents.html Lua tutorial] ===&lt;br /&gt;
If you are new to Lua and programming as such and if you are eager to learn, this is your starting point. Before you proceed to NETIO Sockets, this [https://www.lua.org/demo.html online environment] will be a good place to test your first scripts.&lt;br /&gt;
&lt;br /&gt;
=== [[NETIO Lua Manual]] ===&lt;br /&gt;
A quick jump into NETIO Lua programming if you mastered another programming language. If you already know Lua, just keep in mind that NETIO Lua loops are limited to 32k cycles and all numbers are integers, not decimals like in standard Lua.&lt;br /&gt;
&lt;br /&gt;
=== [[NETIO Lua Reference]] ===&lt;br /&gt;
If you can already code in Lua, NETIO-specific Lua functions is your main guide to programm NETIO Sockets.&lt;br /&gt;
&lt;br /&gt;
=== [https://www.lua.org/manual/5.3/ Lua manual] ===&lt;br /&gt;
Although you won't need everything mentioned here, it is worth to peek here from time to time to grasp the concepts of effective Lua programming.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;/div&gt;</summary>
		<author><name>Jturon</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=Welcome_to_NETIO_resources_%26_projects_%26_documentation_overview&amp;diff=344</id>
		<title>Welcome to NETIO resources &amp; projects &amp; documentation overview</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=Welcome_to_NETIO_resources_%26_projects_%26_documentation_overview&amp;diff=344"/>
		<updated>2017-05-05T18:22:55Z</updated>

		<summary type="html">&lt;p&gt;Jturon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;script&amp;gt;&lt;br /&gt;
  alert(&amp;quot;aa&amp;quot;);&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;[[Soubor:Netio-logo.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;inline-block; float: left; padding: 0 2em; width: 40%; min-width: 15em; text-align: justify;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;h2 style=&amp;quot;background: #005f41; color: #FFF; margin: 0 -1em; padding: 0 1em;&amp;quot;&amp;gt; Introducing NETIO &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;inline-block; float: left; padding: 0 2em; border-left: 1px solid gray; width: 40%; min-width: 15em; text-align: justify;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;h2 style=&amp;quot;background: #005f41; color: #FFF; margin: 0 -1em; padding: 0 1em;&amp;quot;&amp;gt; NETIO Programming &amp;lt;/h2&amp;gt;&lt;br /&gt;
NETIO uses Lua as its scripting language. To master it, follow these references:&lt;br /&gt;
&lt;br /&gt;
=== [https://www.lua.org/pil/contents.html Lua tutorial] ===&lt;br /&gt;
If you are new to Lua and programming as such and if you are eager to learn, this is your starting point. Before you proceed to NETIO Sockets, this [https://www.lua.org/demo.html online environment] will be a good place to test your first scripts.&lt;br /&gt;
&lt;br /&gt;
=== [[NETIO Lua Manual]] ===&lt;br /&gt;
A quick jump into NETIO Lua programming if you mastered another programming language. If you already know Lua, just keep in mind that NETIO Lua loops are limited to 32k cycles and all numbers are integers, not decimals like in standard Lua.&lt;br /&gt;
&lt;br /&gt;
=== [[NETIO Lua Reference]] ===&lt;br /&gt;
If you can already code in Lua, NETIO-specific Lua functions is your main guide to programm NETIO Sockets.&lt;br /&gt;
&lt;br /&gt;
=== [https://www.lua.org/manual/5.3/ Lua manual] ===&lt;br /&gt;
Although you won't need everything mentioned here, it is worth to peek here from time to time to grasp the concepts of effective Lua programming.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;/div&gt;</summary>
		<author><name>Jturon</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=Welcome_to_NETIO_resources_%26_projects_%26_documentation_overview&amp;diff=343</id>
		<title>Welcome to NETIO resources &amp; projects &amp; documentation overview</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=Welcome_to_NETIO_resources_%26_projects_%26_documentation_overview&amp;diff=343"/>
		<updated>2017-05-05T18:19:28Z</updated>

		<summary type="html">&lt;p&gt;Jturon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;style&amp;gt;&lt;br /&gt;
 h1 { display: none; }&lt;br /&gt;
&amp;lt;/style&amp;gt;&lt;br /&gt;
&amp;lt;center&amp;gt;[[Soubor:Netio-logo.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;inline-block; float: left; padding: 0 2em; width: 40%; min-width: 15em; text-align: justify;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;h2 style=&amp;quot;background: #005f41; color: #FFF; margin: 0 -1em; padding: 0 1em;&amp;quot;&amp;gt; Introducing NETIO &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;inline-block; float: left; padding: 0 2em; border-left: 1px solid gray; width: 40%; min-width: 15em; text-align: justify;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;h2 style=&amp;quot;background: #005f41; color: #FFF; margin: 0 -1em; padding: 0 1em;&amp;quot;&amp;gt; NETIO Programming &amp;lt;/h2&amp;gt;&lt;br /&gt;
NETIO uses Lua as its scripting language. To master it, follow these references:&lt;br /&gt;
&lt;br /&gt;
=== [https://www.lua.org/pil/contents.html Lua tutorial] ===&lt;br /&gt;
If you are new to Lua and programming as such and if you are eager to learn, this is your starting point. Before you proceed to NETIO Sockets, this [https://www.lua.org/demo.html online environment] will be a good place to test your first scripts.&lt;br /&gt;
&lt;br /&gt;
=== [[NETIO Lua Manual]] ===&lt;br /&gt;
A quick jump into NETIO Lua programming if you mastered another programming language. If you already know Lua, just keep in mind that NETIO Lua loops are limited to 32k cycles and all numbers are integers, not decimals like in standard Lua.&lt;br /&gt;
&lt;br /&gt;
=== [[NETIO Lua Reference]] ===&lt;br /&gt;
If you can already code in Lua, NETIO-specific Lua functions is your main guide to programm NETIO Sockets.&lt;br /&gt;
&lt;br /&gt;
=== [https://www.lua.org/manual/5.3/ Lua manual] ===&lt;br /&gt;
Although you won't need everything mentioned here, it is worth to peek here from time to time to grasp the concepts of effective Lua programming.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;/div&gt;</summary>
		<author><name>Jturon</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=Welcome_to_NETIO_resources_%26_projects_%26_documentation_overview&amp;diff=342</id>
		<title>Welcome to NETIO resources &amp; projects &amp; documentation overview</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=Welcome_to_NETIO_resources_%26_projects_%26_documentation_overview&amp;diff=342"/>
		<updated>2017-05-05T18:18:50Z</updated>

		<summary type="html">&lt;p&gt;Jturon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;center&amp;gt;[[Soubor:Netio-logo.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;inline-block; float: left; padding: 0 2em; width: 40%; min-width: 15em; text-align: justify;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;h2 style=&amp;quot;background: #005f41; color: #FFF; margin: 0 -1em; padding: 0 1em;&amp;quot;&amp;gt; Introducing NETIO &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;inline-block; float: left; padding: 0 2em; border-left: 1px solid gray; width: 40%; min-width: 15em; text-align: justify;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;h2 style=&amp;quot;background: #005f41; color: #FFF; margin: 0 -1em; padding: 0 1em;&amp;quot;&amp;gt; NETIO Programming &amp;lt;/h2&amp;gt;&lt;br /&gt;
NETIO uses Lua as its scripting language. To master it, follow these references:&lt;br /&gt;
&lt;br /&gt;
=== [https://www.lua.org/pil/contents.html Lua tutorial] ===&lt;br /&gt;
If you are new to Lua and programming as such and if you are eager to learn, this is your starting point. Before you proceed to NETIO Sockets, this [https://www.lua.org/demo.html online environment] will be a good place to test your first scripts.&lt;br /&gt;
&lt;br /&gt;
=== [[NETIO Lua Manual]] ===&lt;br /&gt;
A quick jump into NETIO Lua programming if you mastered another programming language. If you already know Lua, just keep in mind that NETIO Lua loops are limited to 32k cycles and all numbers are integers, not decimals like in standard Lua.&lt;br /&gt;
&lt;br /&gt;
=== [[NETIO Lua Reference]] ===&lt;br /&gt;
If you can already code in Lua, NETIO-specific Lua functions is your main guide to programm NETIO Sockets.&lt;br /&gt;
&lt;br /&gt;
=== [https://www.lua.org/manual/5.3/ Lua manual] ===&lt;br /&gt;
Although you won't need everything mentioned here, it is worth to peek here from time to time to grasp the concepts of effective Lua programming.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;/div&gt;</summary>
		<author><name>Jturon</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=Welcome_to_NETIO_resources_%26_projects_%26_documentation_overview&amp;diff=341</id>
		<title>Welcome to NETIO resources &amp; projects &amp; documentation overview</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=Welcome_to_NETIO_resources_%26_projects_%26_documentation_overview&amp;diff=341"/>
		<updated>2017-05-05T18:17:41Z</updated>

		<summary type="html">&lt;p&gt;Jturon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;center&amp;gt;[[Soubor:Netio-logo.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;inline-block; float: left; padding: 0 2em; width: 40%; min-width: 15em; text-align: justify;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;h2 style=&amp;quot;background: #005f41; color: #FFF; margin: 0 -1em; padding: 0 1em;&amp;quot;&amp;gt; Introducing NETIO &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;inline-block; float: left; padding: 0 2em; border-left: 1px solid gray; width: 40%; min-width: 15em; text-align: justify;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;h2 style=&amp;quot;background: #005f41; color: #FFF; margin: 0 -1em; padding: 0 1em;&amp;quot;&amp;gt; NETIO Programming &amp;lt;/h2&amp;gt;&lt;br /&gt;
NETIO uses Lua as its scripting language. To master it, follow these references:&lt;br /&gt;
&lt;br /&gt;
=== [https://www.lua.org/pil/contents.html Lua tutorial] ===&lt;br /&gt;
If you are new to Lua and programming as such and if you are eager to learn, this is your starting point. Before you proceed to NETIO Sockets, this [https://www.lua.org/demo.html online environment] will be a good place to test your first scripts.&lt;br /&gt;
&lt;br /&gt;
=== [[NETIO Lua Manual]] ===&lt;br /&gt;
A quick jump into NETIO Lua programming if you mastered another programming language. If you already know Lua, just keep in mind that NETIO Lua loops are limited to 32k cycles and all numbers are integers, not decimals like in standard Lua.&lt;br /&gt;
&lt;br /&gt;
=== [[NETIO Lua Reference]] ===&lt;br /&gt;
If you can already code in Lua, NETIO-specific Lua functions is your main guide to programm NETIO Sockets.&lt;br /&gt;
&lt;br /&gt;
=== [https://www.lua.org/manual/5.3/ Lua manual] ===&lt;br /&gt;
Although you won't need everything mentioned here, it is worth to peek here from time to time to grasp the concepts of effective Lua programming.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;br /&gt;
__NOTITLE__&lt;/div&gt;</summary>
		<author><name>Jturon</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=Welcome_to_NETIO_resources_%26_projects_%26_documentation_overview&amp;diff=340</id>
		<title>Welcome to NETIO resources &amp; projects &amp; documentation overview</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=Welcome_to_NETIO_resources_%26_projects_%26_documentation_overview&amp;diff=340"/>
		<updated>2017-05-05T18:16:37Z</updated>

		<summary type="html">&lt;p&gt;Jturon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;center&amp;gt;[[Soubor:Netio-logo.png]]&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;inline-block; float: left; padding: 0 2em; width: 40%; min-width: 15em; text-align: justify;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;h2 style=&amp;quot;background: #005f41; color: #FFF; margin: 0 -1em; padding: 0 1em;&amp;quot;&amp;gt; Introducing NETIO &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;inline-block; float: left; padding: 0 2em; border-left: 1px solid gray; width: 40%; min-width: 15em; text-align: justify;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;h2 style=&amp;quot;background: #005f41; color: #FFF; margin: 0 -1em; padding: 0 1em;&amp;quot;&amp;gt; NETIO Programming &amp;lt;/h2&amp;gt;&lt;br /&gt;
NETIO uses Lua as its scripting language. To master it, follow these references:&lt;br /&gt;
&lt;br /&gt;
=== [https://www.lua.org/pil/contents.html Lua tutorial] ===&lt;br /&gt;
If you are new to Lua and programming as such and if you are eager to learn, this is your starting point. Before you proceed to NETIO Sockets, this [https://www.lua.org/demo.html online environment] will be a good place to test your first scripts.&lt;br /&gt;
&lt;br /&gt;
=== [[NETIO Lua Manual]] ===&lt;br /&gt;
A quick jump into NETIO Lua programming if you mastered another programming language. If you already know Lua, just keep in mind that NETIO Lua loops are limited to 32k cycles and all numbers are integers, not decimals like in standard Lua.&lt;br /&gt;
&lt;br /&gt;
=== [[NETIO Lua Reference]] ===&lt;br /&gt;
If you can already code in Lua, NETIO-specific Lua functions is your main guide to programm NETIO Sockets.&lt;br /&gt;
&lt;br /&gt;
=== [https://www.lua.org/manual/5.3/ Lua manual] ===&lt;br /&gt;
Although you won't need everything mentioned here, it is worth to peek here from time to time to grasp the concepts of effective Lua programming.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;/div&gt;</summary>
		<author><name>Jturon</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=NETIO_programming&amp;diff=338</id>
		<title>NETIO programming</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=NETIO_programming&amp;diff=338"/>
		<updated>2017-05-05T17:51:04Z</updated>

		<summary type="html">&lt;p&gt;Jturon: Založena nová stránka s textem „Netio uses Lua as its scripting language. To master it, follow these references: * [https://www.lua.org/pil/contents.html Lua tutorial] - If you are new to…“&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Netio uses Lua as its scripting language. To master it, follow these references:&lt;br /&gt;
* [https://www.lua.org/pil/contents.html Lua tutorial] - If you are new to Lua and programming as such and if you are eager to learn, this is your starting point. Before you proceed to Netio Sockets, this [https://www.lua.org/demo.html online environment] will be a good place to test your first scripts.&lt;br /&gt;
* [[Netio Lua Manual]] - A quick jump into Netio Lua programming if you mastered another programming language. If you already know Lua, just keep in mind that Netio Lua loops are limited to 32k cycles and all numbers are integers, not decimals like in standard Lua.&lt;br /&gt;
* [[Netio Lua Reference]] - If you can already code in Lua, Netio-specific Lua functions is your main guide to programm Netio Sockets.&lt;br /&gt;
* [https://www.lua.org/manual/5.3/ Lua manual] - Although you won't need everything mentioned here, it is worth to peek here from time to time to grasp the concepts of effective Lua programming.&lt;/div&gt;</summary>
		<author><name>Jturon</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=Function_devices.system.SetOut()&amp;diff=337</id>
		<title>Function devices.system.SetOut()</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=Function_devices.system.SetOut()&amp;diff=337"/>
		<updated>2017-05-05T17:28:00Z</updated>

		<summary type="html">&lt;p&gt;Jturon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:function devices.system.SetOut()}}&lt;br /&gt;
Changes the state (on or off) of the outlet.&lt;br /&gt;
 &amp;lt;i&amp;gt;nil&amp;lt;/i&amp;gt; &amp;lt;b&amp;gt;devices.system.SetOut&amp;lt;/b&amp;gt;(&amp;lt;i&amp;gt;table&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;config&amp;lt;/code&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
 &amp;lt;i&amp;gt;table&amp;lt;/i&amp;gt; config{&amp;lt;code&amp;gt;output&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;value&amp;lt;/code&amp;gt;}&lt;br /&gt;
* &amp;lt;i&amp;gt;number&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;output&amp;lt;/code&amp;gt; outlet to change (1 to 4)&lt;br /&gt;
* &amp;lt;i&amp;gt;boolean&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;value&amp;lt;/code&amp;gt;&lt;br /&gt;
** &amp;lt;tt&amp;gt;true&amp;lt;/tt&amp;gt; = turn on&lt;br /&gt;
** &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; = turn off&lt;br /&gt;
&lt;br /&gt;
=== Return value ===&lt;br /&gt;
 nil&lt;br /&gt;
&lt;br /&gt;
=== Usage ===&lt;br /&gt;
 -- turns outlet No.1 on&lt;br /&gt;
 devices.system.SetOut{output=1,value=true}&lt;br /&gt;
&lt;br /&gt;
=== See also ===&lt;br /&gt;
* [[Function devices.system.ResetOut()|devices.system.ResetOut()]] to conveniently reset the state&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;/div&gt;</summary>
		<author><name>Jturon</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=Function_devices.system.ResetOut()&amp;diff=336</id>
		<title>Function devices.system.ResetOut()</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=Function_devices.system.ResetOut()&amp;diff=336"/>
		<updated>2017-05-05T17:27:39Z</updated>

		<summary type="html">&lt;p&gt;Jturon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:function devices.system.ResetOut()}}&lt;br /&gt;
Resets the outlet: if it was off, it stays off. If it was on, it is turned off for specified time (its led blinks green), and then turned on again.&lt;br /&gt;
 &amp;lt;i&amp;gt;nil&amp;lt;/i&amp;gt; &amp;lt;b&amp;gt;devices.system.ResetOut&amp;lt;/b&amp;gt;(&amp;lt;i&amp;gt;table&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;config&amp;lt;/code&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
 &amp;lt;i&amp;gt;table&amp;lt;/i&amp;gt; config{&amp;lt;code&amp;gt;output&amp;lt;/code&amp;gt;, &amp;lt;code style=&amp;quot;color: #777&amp;quot;&amp;gt;resetDelay&amp;lt;/code&amp;gt;}&lt;br /&gt;
* &amp;lt;i&amp;gt;number&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;output&amp;lt;/code&amp;gt; outlet to reset (1 to 4)&lt;br /&gt;
* optional &amp;lt;i&amp;gt;number&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;resetDelay&amp;lt;/code&amp;gt; time period (in seconds) to keep the outlet off (default 1)&lt;br /&gt;
&lt;br /&gt;
=== Return value ===&lt;br /&gt;
 nil&lt;br /&gt;
&lt;br /&gt;
=== Usage ===&lt;br /&gt;
 -- turns outlet No.1 off and resets its previous state after 10 seconds&lt;br /&gt;
 devices.system.ResetOut{output=1,resetDelay=10}&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;/div&gt;</summary>
		<author><name>Jturon</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=Function_ping()&amp;diff=335</id>
		<title>Function ping()</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=Function_ping()&amp;diff=335"/>
		<updated>2017-05-05T17:25:20Z</updated>

		<summary type="html">&lt;p&gt;Jturon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:function ping()}}&lt;br /&gt;
Test connection to specified IP or URL using ICMP packet&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;i&amp;gt;nil&amp;lt;/i&amp;gt; &amp;lt;b&amp;gt;ping&amp;lt;/b&amp;gt;(&amp;lt;i&amp;gt;table&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;config&amp;lt;/code&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
 &amp;lt;i&amp;gt;table&amp;lt;/i&amp;gt; config{&amp;lt;code&amp;gt;address&amp;lt;/code&amp;gt;, &amp;lt;code style=&amp;quot;color: #777&amp;quot;&amp;gt;timeout&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;callback&amp;lt;/code&amp;gt;}&lt;br /&gt;
* &amp;lt;i&amp;gt;string&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;address&amp;lt;/code&amp;gt; IP or URL (without http://) to test&lt;br /&gt;
* optional &amp;lt;i&amp;gt;number&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;timeout&amp;lt;/code&amp;gt; maximal wait for response (in seconds)&lt;br /&gt;
* &amp;lt;i&amp;gt;function{response}&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;callback&amp;lt;/code&amp;gt; this function is called when response arrives or timeout is reached&lt;br /&gt;
&lt;br /&gt;
=== Callback Parameters ===&lt;br /&gt;
 &amp;lt;i&amp;gt;table&amp;lt;/i&amp;gt; response{&amp;lt;code&amp;gt;success&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;duration&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;errorInfo&amp;lt;/code&amp;gt;}&lt;br /&gt;
* &amp;lt;i&amp;gt;boolean&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;success&amp;lt;/code&amp;gt; false = timeout reached, true = response confirmed before timeout&lt;br /&gt;
* &amp;lt;i&amp;gt;number&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;duration&amp;lt;/code&amp;gt; response delay (in milliseconds); if not success, duration is &amp;lt;tt&amp;gt;nil&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;i&amp;gt;string&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;errorInfo&amp;lt;/code&amp;gt; error info in case of failure. If success, it contains &amp;quot;No error, return OK&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Return value ===&lt;br /&gt;
 nil&lt;br /&gt;
&lt;br /&gt;
=== Usage ===&lt;br /&gt;
 -- callback function&lt;br /&gt;
 local function logPingResult(o)&lt;br /&gt;
   if o.success then&lt;br /&gt;
     logf(&amp;quot;Response lag: %dms&amp;quot;, o.duration)&lt;br /&gt;
   else&lt;br /&gt;
     logf(&amp;quot;Ping failed, reason: %s&amp;quot;, o.errorInfo)&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 -- test ping www.google.com&lt;br /&gt;
 ping{address=&amp;quot;www.google.com&amp;quot;, timeout=10, callback=logPingResult}&lt;br /&gt;
 &lt;br /&gt;
 -- test ping ip address&lt;br /&gt;
 ping{address=&amp;quot;77.75.79.39&amp;quot;, callback=logPingResult}&lt;br /&gt;
 &lt;br /&gt;
 -- test ping non-existent address&lt;br /&gt;
 ping{address=&amp;quot;Pandora&amp;quot;, timeout=2, callback=logPingResult}&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;/div&gt;</summary>
		<author><name>Jturon</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=Function_devices.system.CustomCGI()&amp;diff=334</id>
		<title>Function devices.system.CustomCGI()</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=Function_devices.system.CustomCGI()&amp;diff=334"/>
		<updated>2017-05-05T17:24:51Z</updated>

		<summary type="html">&lt;p&gt;Jturon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:function devices.system.CustomCGI()}}&lt;br /&gt;
Execute HTTP GET call to given url. The call is one-way only. To read the HTTP response, use [[CgiGet()]].&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;i&amp;gt;nil&amp;lt;/i&amp;gt; &amp;lt;b&amp;gt;devices.system.CustomCGI&amp;lt;/b&amp;gt;(&amp;lt;i&amp;gt;table&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;config&amp;lt;/code&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
 &amp;lt;i&amp;gt;table&amp;lt;/i&amp;gt; config{&amp;lt;code&amp;gt;url&amp;lt;/code&amp;gt;}&lt;br /&gt;
* &amp;lt;i&amp;gt;string&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;url&amp;lt;/code&amp;gt; address to call&lt;br /&gt;
&lt;br /&gt;
=== Return value ===&lt;br /&gt;
 nil&lt;br /&gt;
&lt;br /&gt;
=== Usage ===&lt;br /&gt;
 -- sends HTTP GET request&lt;br /&gt;
 devices.system.CustomCGI{url=&amp;quot;http://192.168.0.1/handler.cgi?outlet=1&amp;amp;state=0&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
=== See also ===&lt;br /&gt;
* [[CgiGet()]] to send HTTP request and handle HTTP response&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;/div&gt;</summary>
		<author><name>Jturon</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=Function_cgiGet()&amp;diff=333</id>
		<title>Function cgiGet()</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=Function_cgiGet()&amp;diff=333"/>
		<updated>2017-05-05T17:23:49Z</updated>

		<summary type="html">&lt;p&gt;Jturon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:function cgiGet()}}&lt;br /&gt;
Execute HTTP GET call to given url and read the response. The call is asynchronous: the code execution proceeds immediately and when the response arrives, callback function is called. To perform simple HTTP GET call without response handling, use simpler [[Devices.system.CustomCGI()|devices.system.CustomCGI()]]&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;i&amp;gt;nil&amp;lt;/i&amp;gt; &amp;lt;b&amp;gt;devices.system.cgiGet&amp;lt;/b&amp;gt;(&amp;lt;i&amp;gt;table&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;config&amp;lt;/code&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
 &amp;lt;i&amp;gt;table&amp;lt;/i&amp;gt; config{&amp;lt;code&amp;gt;url&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;callback&amp;lt;/code&amp;gt;, &amp;lt;code style=&amp;quot;color: #777&amp;quot;&amp;gt;timeout&amp;lt;/code&amp;gt;, &amp;lt;code style=&amp;quot;color: #777&amp;quot;&amp;gt;bufferSize&amp;lt;/code&amp;gt;}&lt;br /&gt;
* &amp;lt;i&amp;gt;string&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;url&amp;lt;/code&amp;gt; address to call&lt;br /&gt;
* &amp;lt;i&amp;gt;function{response}&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;callback&amp;lt;/code&amp;gt; this function is called when response arrives&lt;br /&gt;
* optional &amp;lt;i&amp;gt;number&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;timeout&amp;lt;/code&amp;gt; maximum seconds to wait for response (default 30)&lt;br /&gt;
* optional &amp;lt;i&amp;gt;number&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;bufferSize&amp;lt;/code&amp;gt; bytes of memory to allocate for response (min. 4k, max 1M)&lt;br /&gt;
&lt;br /&gt;
=== Callback Parameters ===&lt;br /&gt;
 &amp;lt;i&amp;gt;table&amp;lt;/i&amp;gt; response{&amp;lt;code&amp;gt;result&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;errInfo&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;received&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;buffer&amp;lt;/code&amp;gt;}&lt;br /&gt;
* &amp;lt;i&amp;gt;number&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;result&amp;lt;/code&amp;gt; error code of the response (see below)&lt;br /&gt;
* &amp;lt;i&amp;gt;string&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;errInfo&amp;lt;/code&amp;gt; error description (if result&amp;gt;0)&lt;br /&gt;
* &amp;lt;i&amp;gt;number&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;received&amp;lt;/code&amp;gt; response length&lt;br /&gt;
* &amp;lt;i&amp;gt;string&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;buffer&amp;lt;/code&amp;gt; response body&lt;br /&gt;
&lt;br /&gt;
=== Error Code of the response ===&lt;br /&gt;
* 0 success, response HTTP/GET 2xx&lt;br /&gt;
* 22 response HTTP/GET 4xx&lt;br /&gt;
* 27 buffer overflow&lt;br /&gt;
* 28 response is timed out&lt;br /&gt;
&lt;br /&gt;
=== Return value ===&lt;br /&gt;
 nil&lt;br /&gt;
&lt;br /&gt;
=== Usage ===&lt;br /&gt;
 -- callback function to read the response&lt;br /&gt;
 local function getResponse{response}&lt;br /&gt;
   if response.result &amp;gt; 0 then&lt;br /&gt;
     logf(&amp;quot;response failed with error code %d.&amp;quot;, response.result)&lt;br /&gt;
   else&lt;br /&gt;
     logf(&amp;quot;current credit is %d&amp;quot;, tonumber(response.buffer))&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 -- sends HTTP request and handles the response&lt;br /&gt;
 devices.system.CgiGet{url=&amp;quot;http://example.com/getcredit?id=42&amp;quot;,getResponse}&lt;br /&gt;
&lt;br /&gt;
=== Requirements ===&lt;br /&gt;
Netio FirmWare 2.3.5+&lt;br /&gt;
&lt;br /&gt;
=== See also ===&lt;br /&gt;
* [[Devices.system.CustomCGI()|devices.system.CustomCGI()]] to send HTTP request without response handling&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;/div&gt;</summary>
		<author><name>Jturon</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=Function_toboolean()&amp;diff=332</id>
		<title>Function toboolean()</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=Function_toboolean()&amp;diff=332"/>
		<updated>2017-05-05T17:22:37Z</updated>

		<summary type="html">&lt;p&gt;Jturon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:function toboolean()}}&lt;br /&gt;
Converts variable to boolean (true or false) value (the only type usable in conditions).&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;i&amp;gt;boolean&amp;lt;/i&amp;gt; toboolean(&amp;lt;i&amp;gt;mixed&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;variable&amp;lt;/code&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
* &amp;lt;i&amp;gt;mixed&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;variable&amp;lt;/code&amp;gt; will be converted to boolean value.&lt;br /&gt;
&lt;br /&gt;
=== Return value ===&lt;br /&gt;
Falsy values are:&lt;br /&gt;
* number 0&lt;br /&gt;
* boolean false&lt;br /&gt;
* string &amp;quot;&amp;quot;&lt;br /&gt;
* table {}&lt;br /&gt;
&lt;br /&gt;
Anything else converts to true.&lt;br /&gt;
&lt;br /&gt;
=== Usage ===&lt;br /&gt;
 local answer = 42&lt;br /&gt;
 if toboolean(answer) then&lt;br /&gt;
   log(&amp;quot;42 is true!&amp;quot;)&lt;br /&gt;
 else&lt;br /&gt;
   log(&amp;quot;42 is false!&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
To use inverse conversion (boolean to number) use 'x and 1 or 0' idiom:&lt;br /&gt;
&lt;br /&gt;
 local x = true&lt;br /&gt;
 logf(&amp;quot;x is %d&amp;quot;, x and 1 or 0)&lt;br /&gt;
&lt;br /&gt;
=== See also ===&lt;br /&gt;
Lua system's tonumber() and tostring() functions.&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;/div&gt;</summary>
		<author><name>Jturon</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=Function_logf()&amp;diff=331</id>
		<title>Function logf()</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=Function_logf()&amp;diff=331"/>
		<updated>2017-05-05T17:21:42Z</updated>

		<summary type="html">&lt;p&gt;Jturon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:function log()}}&lt;br /&gt;
Insert a formated record into the socket's event log. Suitable for debugging purposes.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;i&amp;gt;nil&amp;lt;/i&amp;gt; &amp;lt;b&amp;gt;logf&amp;lt;/b&amp;gt;(&amp;lt;i&amp;gt;string&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;message&amp;lt;/code&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
* &amp;lt;i&amp;gt;string&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;message&amp;lt;/code&amp;gt; will be inserted into the event log. Can use tokens described below. The tokens will be replaced by following parameters (variable arguments).&lt;br /&gt;
&lt;br /&gt;
=== Tokens ===&lt;br /&gt;
* &amp;lt;code&amp;gt;%d&amp;lt;/code&amp;gt; is substituted by following argument as a number&lt;br /&gt;
* &amp;lt;code&amp;gt;%s&amp;lt;/code&amp;gt; is substituted by following argument as a number&lt;br /&gt;
&lt;br /&gt;
There is no &amp;lt;code&amp;gt;%b&amp;lt;/code&amp;gt; token to display boolean values. To display boolean x as a number, use 'x and 1 or 0' idiom (true as 1, false as 0).&lt;br /&gt;
&lt;br /&gt;
=== Return value ===&lt;br /&gt;
 nil&lt;br /&gt;
&lt;br /&gt;
=== Usage ===&lt;br /&gt;
 local a = 42&lt;br /&gt;
 local b = false&lt;br /&gt;
 local c = &amp;quot;Hello&amp;quot;;&lt;br /&gt;
 &lt;br /&gt;
 -- displays 'test: 42, 0, Hello.'&lt;br /&gt;
 log(&amp;quot;test: %d, %d, %s.&amp;quot;, a, b and 1 or 0, c)&lt;br /&gt;
&lt;br /&gt;
=== See also ===&lt;br /&gt;
* [[Function log()|log()]] to display unformatted string and system properties&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;/div&gt;</summary>
		<author><name>Jturon</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=Function_log()&amp;diff=330</id>
		<title>Function log()</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=Function_log()&amp;diff=330"/>
		<updated>2017-05-05T17:21:24Z</updated>

		<summary type="html">&lt;p&gt;Jturon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:function log()}}&lt;br /&gt;
Insert a record into the socket's event log. Suitable for debugging purposes.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;i&amp;gt;nil&amp;lt;/i&amp;gt; &amp;lt;b&amp;gt;log&amp;lt;/b&amp;gt;(&amp;lt;i&amp;gt;string&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;message&amp;lt;/code&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
* &amp;lt;i&amp;gt;string&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;message&amp;lt;/code&amp;gt; will be inserted into the event log. Can display socket properties using ${property} syntax - see the example below.&lt;br /&gt;
&lt;br /&gt;
=== Return value ===&lt;br /&gt;
 nil&lt;br /&gt;
&lt;br /&gt;
=== Usage ===&lt;br /&gt;
 -- prints i.e. 'The power of outlet 1 is 17 Watts.'&lt;br /&gt;
 log(&amp;quot;The power of outlet 1 is ${devices.system.output1_consumption} Watts.&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
=== See also ===&lt;br /&gt;
* [[Function logf()|logf()]] to display formatted string&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;/div&gt;</summary>
		<author><name>Jturon</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=Function_xml.parse()&amp;diff=329</id>
		<title>Function xml.parse()</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=Function_xml.parse()&amp;diff=329"/>
		<updated>2017-05-05T17:20:10Z</updated>

		<summary type="html">&lt;p&gt;Jturon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:function xml.check()}}&lt;br /&gt;
Parses xml string.&lt;br /&gt;
 &amp;lt;i&amp;gt;XmlElement&amp;lt;/i&amp;gt; &amp;lt;b&amp;gt;xml.parse&amp;lt;/b&amp;gt;(&amp;lt;i&amp;gt;string&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;xml&amp;lt;/code&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
* &amp;lt;i&amp;gt;string&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;xml&amp;lt;/code&amp;gt; string to parse&lt;br /&gt;
&lt;br /&gt;
=== Return value ===&lt;br /&gt;
 XmlElement&lt;br /&gt;
&lt;br /&gt;
Consecutive spaces are trimmed to single space.&lt;br /&gt;
&lt;br /&gt;
== XmlElement ==&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;i&amp;gt;string&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;name&amp;lt;/code&amp;gt; ===&lt;br /&gt;
name of the node&lt;br /&gt;
 log(xml.parse(&amp;quot;&amp;lt;note&amp;gt;something&amp;lt;/note&amp;gt;&amp;quot;).name) -- note&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;i&amp;gt;string&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;text&amp;lt;/code&amp;gt; ===&lt;br /&gt;
text content of the node (excluding the contents of child nodes). To read all content as a text, use .innerXml (see below)&lt;br /&gt;
 local data = xml.parse(&amp;quot;&amp;lt;note&amp;gt;something &amp;amp;lt;big&amp;gt;really&amp;amp;lt;/big&amp;gt; good&amp;lt;/note&amp;gt;&amp;quot;)&lt;br /&gt;
 log(data.text) -- something good&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;i&amp;gt;string/nil&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;attr(&amp;lt;i&amp;gt;string&amp;lt;/i&amp;gt; name)&amp;lt;/code&amp;gt; ===&lt;br /&gt;
returns the value of a single attribute; if the attribute doesn't exists, ruturns &amp;lt;i&amp;gt;nil&amp;lt;/i&amp;gt;&lt;br /&gt;
 local data = xml.parse('&amp;lt;note from=&amp;quot;ann&amp;quot; to=&amp;quot;bob&amp;quot;&amp;gt;hello&amp;lt;/note&amp;gt;')&lt;br /&gt;
 log(data.attr(&amp;quot;from&amp;quot;)) -- ann&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;i&amp;gt;table&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;attr()&amp;lt;/code&amp;gt; ===&lt;br /&gt;
returns all attributes as a table&lt;br /&gt;
 local data = xml.parse('&amp;lt;note from=&amp;quot;ann&amp;quot; to=&amp;quot;bob&amp;quot;&amp;gt;hello&amp;lt;/note&amp;gt;')&lt;br /&gt;
 local attrs = data.attr()&lt;br /&gt;
 logf(&amp;quot;%s -&amp;gt; %s&amp;quot;, attrs.from, attrs[&amp;quot;to&amp;quot;]) -- ann -&amp;gt; bob&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;i&amp;gt;XmlElement/nil&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;child(&amp;lt;i&amp;gt;string&amp;lt;/i&amp;gt; name)&amp;lt;/code&amp;gt; ===&lt;br /&gt;
returns first child node with given name, nil if no such element is found&lt;br /&gt;
 local data = [[&lt;br /&gt;
   &amp;lt;papers&amp;gt;&lt;br /&gt;
     &amp;lt;book&amp;gt;Bible&amp;lt;/book&amp;gt;&lt;br /&gt;
     &amp;lt;magazine&amp;gt;Automoto Revue&amp;lt;/magazine&amp;gt;&lt;br /&gt;
     &amp;lt;book&amp;gt;Quran&amp;lt;/book&amp;gt;&lt;br /&gt;
   &amp;lt;/papers&amp;gt;&lt;br /&gt;
 ]]&lt;br /&gt;
 local parsed = xml.parse(data)&lt;br /&gt;
 log(parsed.child(&amp;quot;book&amp;quot;).text) -- Bible&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;i&amp;gt;array&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;children(optional &amp;lt;i&amp;gt;string&amp;lt;/i&amp;gt; name)&amp;lt;/code&amp;gt; ===&lt;br /&gt;
returns all child nodes; if name is provided, the nodes are filtered by the name&lt;br /&gt;
 local data = [[&lt;br /&gt;
   &amp;lt;papers&amp;gt;&lt;br /&gt;
     &amp;lt;book&amp;gt;Bible&amp;lt;/book&amp;gt;&lt;br /&gt;
     &amp;lt;magazine&amp;gt;Automoto Revue&amp;lt;/magazine&amp;gt;&lt;br /&gt;
     &amp;lt;book&amp;gt;Quran&amp;lt;/book&amp;gt;&lt;br /&gt;
   &amp;lt;/papers&amp;gt;&lt;br /&gt;
 ]]&lt;br /&gt;
 local parsed = xml.parse(data)&lt;br /&gt;
 log(parsed.children(&amp;quot;book&amp;quot;)[2].text) -- Quran&lt;br /&gt;
 log(parsed.children()[2].text) -- Automoto Revue&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;i&amp;gt;XmlElement/nil&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;get(&amp;lt;i&amp;gt;string/number&amp;lt;/i&amp;gt;...)&amp;lt;/code&amp;gt; ===&lt;br /&gt;
traverses the xml tree and filters the result for each argument:&lt;br /&gt;
* &amp;lt;i&amp;gt;string&amp;lt;/i&amp;gt; descend into first node of given name&lt;br /&gt;
* &amp;lt;i&amp;gt;number&amp;lt;/i&amp;gt; descend into n-th node of name specified by previous argument&lt;br /&gt;
 local data = [[&lt;br /&gt;
 &amp;lt;root&amp;gt;&lt;br /&gt;
   &amp;lt;papers&amp;gt;&lt;br /&gt;
     &amp;lt;book&amp;gt;Bible&amp;lt;/book&amp;gt;&lt;br /&gt;
   &amp;lt;/papers&amp;gt;&lt;br /&gt;
   &amp;lt;papers&amp;gt;&lt;br /&gt;
     &amp;lt;magazine&amp;gt;Automoto Revue&amp;lt;/magazine&amp;gt;&lt;br /&gt;
     &amp;lt;book&amp;gt;Quran&amp;lt;/book&amp;gt;&lt;br /&gt;
   &amp;lt;/papers&amp;gt;&lt;br /&gt;
 &amp;lt;/root&amp;gt;&lt;br /&gt;
 ]]&lt;br /&gt;
 local parsed = xml.parse(data)&lt;br /&gt;
 log(parsed.get(&amp;quot;papers&amp;quot;,2,&amp;quot;book&amp;quot;).text) -- Quran&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;i&amp;gt;XmlElement/nil&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;next&amp;lt;/code&amp;gt; ===&lt;br /&gt;
next sibling node of the same name&lt;br /&gt;
 local data = [[&lt;br /&gt;
   &amp;lt;papers&amp;gt;&lt;br /&gt;
     &amp;lt;book&amp;gt;Bible&amp;lt;/book&amp;gt;&lt;br /&gt;
     &amp;lt;magazine&amp;gt;Automoto Revue&amp;lt;/magazine&amp;gt;&lt;br /&gt;
     &amp;lt;book&amp;gt;Quran&amp;lt;/book&amp;gt;&lt;br /&gt;
   &amp;lt;/papers&amp;gt;&lt;br /&gt;
 ]]&lt;br /&gt;
 local parsed = xml.parse(data)&lt;br /&gt;
 log(parsed.child(&amp;quot;book&amp;quot;).next.text) -- Quran&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;i&amp;gt;string&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;xml&amp;lt;/code&amp;gt; ===&lt;br /&gt;
inner xml of parent XmlElement&lt;br /&gt;
 local data = [[&lt;br /&gt;
   &amp;lt;papers&amp;gt;&lt;br /&gt;
     &amp;lt;book&amp;gt;Bible&amp;lt;/book&amp;gt;&lt;br /&gt;
     &amp;lt;magazine&amp;gt;Automoto Revue&amp;lt;/magazine&amp;gt;&lt;br /&gt;
     &amp;lt;book&amp;gt;Quran&amp;lt;/book&amp;gt;&lt;br /&gt;
   &amp;lt;/papers&amp;gt;&lt;br /&gt;
 ]]&lt;br /&gt;
 local parsed = xml.parse(data)&lt;br /&gt;
 log(parsed.child(&amp;quot;book&amp;quot;).xml)&lt;br /&gt;
 -- &amp;lt;book&amp;gt;Bible&amp;lt;/book&amp;gt; &amp;lt;magazine&amp;gt;Automoto Revue&amp;lt;/magazine&amp;gt; &amp;lt;book&amp;gt;Quran&amp;lt;/book&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;i&amp;gt;string&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;innerXml&amp;lt;/code&amp;gt; ===&lt;br /&gt;
inner xml of parent XmlElement&lt;br /&gt;
 local data = [[&lt;br /&gt;
   &amp;lt;papers&amp;gt;&lt;br /&gt;
     &amp;lt;book&amp;gt;Bible&amp;lt;/book&amp;gt;&lt;br /&gt;
     &amp;lt;magazine&amp;gt;Automoto Revue&amp;lt;/magazine&amp;gt;&lt;br /&gt;
     &amp;lt;book&amp;gt;Quran&amp;lt;/book&amp;gt;&lt;br /&gt;
   &amp;lt;/papers&amp;gt;&lt;br /&gt;
 ]]&lt;br /&gt;
 local parsed = xml.parse(data)&lt;br /&gt;
 log(parsed.innerXml)&lt;br /&gt;
 -- &amp;lt;book&amp;gt;Bible&amp;lt;/book&amp;gt; &amp;lt;magazine&amp;gt;Automoto Revue&amp;lt;/magazine&amp;gt; &amp;lt;book&amp;gt;Quran&amp;lt;/book&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;i&amp;gt;XmlElement/nil&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;parent&amp;lt;/code&amp;gt; ===&lt;br /&gt;
parent node&lt;br /&gt;
 local data = [[&lt;br /&gt;
   &amp;lt;papers&amp;gt;&lt;br /&gt;
     &amp;lt;book&amp;gt;Bible&amp;lt;/book&amp;gt;&lt;br /&gt;
     &amp;lt;magazine&amp;gt;Automoto Revue&amp;lt;/magazine&amp;gt;&lt;br /&gt;
     &amp;lt;bool&amp;gt;Quran&amp;lt;/bool&amp;gt;&lt;br /&gt;
   &amp;lt;/papers&amp;gt;&lt;br /&gt;
 ]]&lt;br /&gt;
 local magazine = xml.parse(data).child(&amp;quot;magazine&amp;quot;)&lt;br /&gt;
 log(magazine.parent.name) -- papers&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;i&amp;gt;XmlElement/nil&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt; ===&lt;br /&gt;
root node (nil for root)&lt;/div&gt;</summary>
		<author><name>Jturon</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=Function_xml.escape()&amp;diff=328</id>
		<title>Function xml.escape()</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=Function_xml.escape()&amp;diff=328"/>
		<updated>2017-05-05T17:19:00Z</updated>

		<summary type="html">&lt;p&gt;Jturon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:function xml.escape()}}&lt;br /&gt;
Escapes XML string to fit xml node contents.&lt;br /&gt;
 &amp;lt;i&amp;gt;string&amp;lt;/i&amp;gt; &amp;lt;b&amp;gt;xml.escape&amp;lt;/b&amp;gt;(&amp;lt;i&amp;gt;string&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;xml&amp;lt;/code&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
* &amp;lt;i&amp;gt;string&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;xml&amp;lt;/code&amp;gt; string to escape&lt;br /&gt;
&lt;br /&gt;
=== Return value ===&lt;br /&gt;
 string&lt;br /&gt;
Escaped characters are&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! input !! output&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt; || &amp;amp;amp;lt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;gt; || &amp;amp;amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;quot; || &amp;amp;amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| ' || &amp;amp;amp;apos;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp; || &amp;amp;amp;amp;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Usage ===&lt;br /&gt;
 -- escape string&lt;br /&gt;
 local note = xml.escape(&amp;quot;3&amp;lt;5&amp;quot;)&lt;br /&gt;
 -- put the escaped string &amp;quot;3&amp;amp;lt;5&amp;quot; into xml node&lt;br /&gt;
 local node = &amp;quot;&amp;lt;note&amp;gt;&amp;quot;..note..&amp;quot;&amp;lt;/note&amp;gt;&amp;quot;&lt;br /&gt;
 -- parse the node&lt;br /&gt;
 local result = xml.parse(node)&lt;br /&gt;
 -- check the contents (text is unescaped: &amp;quot;3&amp;lt;5&amp;quot;)&lt;br /&gt;
 log(result.text)&lt;br /&gt;
&lt;br /&gt;
=== See also ===&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;/div&gt;</summary>
		<author><name>Jturon</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=Function_xml.check()&amp;diff=327</id>
		<title>Function xml.check()</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=Function_xml.check()&amp;diff=327"/>
		<updated>2017-05-05T17:17:43Z</updated>

		<summary type="html">&lt;p&gt;Jturon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:function xml.check()}}&lt;br /&gt;
Tests if string is well-formed XML.&lt;br /&gt;
 &amp;lt;i&amp;gt;boolean&amp;lt;/i&amp;gt; &amp;lt;b&amp;gt;xml.check&amp;lt;/b&amp;gt;(&amp;lt;i&amp;gt;string&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;xml&amp;lt;/code&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
* &amp;lt;i&amp;gt;string&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;xml&amp;lt;/code&amp;gt; string to escape&lt;br /&gt;
&lt;br /&gt;
=== Return value ===&lt;br /&gt;
 boolean&lt;br /&gt;
* true if &amp;lt;code&amp;gt;xmlstring&amp;lt;/code&amp;gt; is well-formed xml&lt;br /&gt;
* false if not&lt;br /&gt;
&lt;br /&gt;
=== Usage ===&lt;br /&gt;
local badnode = &amp;quot;&amp;lt;note&amp;gt;&amp;quot;..&amp;quot;3&amp;lt;5&amp;quot;..&amp;quot;&amp;lt;/note&amp;gt;&amp;quot;&lt;br /&gt;
local goodnode = &amp;quot;&amp;lt;note&amp;gt;&amp;quot;..xml.escape(&amp;quot;3&amp;lt;5&amp;quot;)..&amp;quot;&amp;lt;/note&amp;gt;&amp;quot;&lt;br /&gt;
log(tostring(xml.check(badnode))) -- false&lt;br /&gt;
log(tostring(xml.check(goodnode))) -- true&lt;br /&gt;
&lt;br /&gt;
=== See also ===&lt;br /&gt;
* [[Function xml.escape()|xml.escape()]] to xml-escape string&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;/div&gt;</summary>
		<author><name>Jturon</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=NETIO_Lua_Manual&amp;diff=326</id>
		<title>NETIO Lua Manual</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=NETIO_Lua_Manual&amp;diff=326"/>
		<updated>2017-05-03T09:50:54Z</updated>

		<summary type="html">&lt;p&gt;Jturon: /* Loops */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Debugging ==&lt;br /&gt;
To debug your code, use [[Function log()|log()]] and [[Function logf()|logf()]] functions. See the output in system events log.&lt;br /&gt;
&lt;br /&gt;
== Data types ==&lt;br /&gt;
Lua supports these data types:&lt;br /&gt;
* &amp;lt;i&amp;gt;nil&amp;lt;/i&amp;gt; (to assign &amp;lt;i&amp;gt;nil&amp;lt;/i&amp;gt; value effectively deletes the variable)&lt;br /&gt;
* &amp;lt;i&amp;gt;boolean&amp;lt;/i&amp;gt; (falsy values are &amp;lt;i&amp;gt;nil&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;false&amp;lt;/i&amp;gt; only; &amp;quot;&amp;quot; and 0 evaluates as &amp;lt;i&amp;gt;true&amp;lt;/i&amp;gt;)&lt;br /&gt;
* &amp;lt;i&amp;gt;number&amp;lt;/i&amp;gt; (decimals only in standard Lua, integers only in Netio Lua)&lt;br /&gt;
* &amp;lt;i&amp;gt;string&amp;lt;/i&amp;gt; (same strings share same address, so equality operator measures both address and value)&lt;br /&gt;
* &amp;lt;i&amp;gt;tables&amp;lt;/i&amp;gt; are associative arrays. (Tables with numeric indices are, well, just arrays.)&lt;br /&gt;
&lt;br /&gt;
 local numbers = {2,3,7,5} -- array (first index = 1)&lt;br /&gt;
 local dictionary = {one=1, two=2, three=3} -- table&lt;br /&gt;
 local numbersZeroBased = {[0]=2,3,7,5} -- array (first index = 0)&lt;br /&gt;
&lt;br /&gt;
== Operators ==&lt;br /&gt;
Lua has its own manners:&lt;br /&gt;
* &amp;lt;code&amp;gt;~=&amp;lt;/code&amp;gt; is inequality operator&lt;br /&gt;
* &amp;lt;code&amp;gt;..&amp;lt;/code&amp;gt; is string concatenation (don't use plus)&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;s&amp;gt;i++&amp;lt;/s&amp;gt;&amp;lt;/code&amp;gt; no increment/decrement operator &amp;lt;code&amp;gt;i = i + 1&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;s&amp;gt;max = a&amp;lt;b ? b : a&amp;lt;/s&amp;gt;&amp;lt;/code&amp;gt; no ternary operator. Use (and get used to) &amp;lt;i&amp;gt;and idiom&amp;lt;/i&amp;gt; instead: &amp;lt;code&amp;gt;max = (a&amp;lt;b) and b or a&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;i&amp;gt;or idiom&amp;lt;/i&amp;gt; works: &amp;lt;code&amp;gt;x = x or 42&amp;lt;/code&amp;gt; is equivalent to &amp;lt;code&amp;gt;if not x then x = 42 end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Conditions ==&lt;br /&gt;
Lua conditions has casual syntax, see [https://www.lua.org/pil/4.3.1.html here]. Just keep in mind to merge &amp;lt;code&amp;gt;else&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;elseif&amp;lt;/code&amp;gt; or multiple &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt;s are required.&lt;br /&gt;
&lt;br /&gt;
Note that falsy values are &amp;lt;i&amp;gt;nil&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;false&amp;lt;/i&amp;gt; only. Empty string and 0 evaluates as true. If you come from C, you might be surprised by following snippet:&lt;br /&gt;
&lt;br /&gt;
 if devices.system.output1_consumption then&lt;br /&gt;
   -- always happens, even if the consumption is 0&lt;br /&gt;
   log(&amp;quot;Outlet 1 supplies power&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 if not devices.system.output1_consumption then&lt;br /&gt;
   -- never happens, even if the consumption is 0&lt;br /&gt;
   log(&amp;quot;Outlet 1 is idle&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
== Loops ==&lt;br /&gt;
Lua has &amp;lt;code&amp;gt;break&amp;lt;/code&amp;gt; statement, but no &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt; (use condition inside loop instead). Additionally, Netio Lua implementation limits the loop iterations to 32k.&lt;br /&gt;
&lt;br /&gt;
=== While ===&lt;br /&gt;
While syntax is not different to other languages:&lt;br /&gt;
 local i = 0&lt;br /&gt;
 while i~=3 do&lt;br /&gt;
   i = i + 1&lt;br /&gt;
   logf(&amp;quot;%d&amp;quot;,i)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
=== Repeat until ===&lt;br /&gt;
Repeat until syntax is the same as Pascal's, other languages have similar do-while loops:&lt;br /&gt;
 local i = 0&lt;br /&gt;
 repeat&lt;br /&gt;
   i = i + 1&lt;br /&gt;
   logf(&amp;quot;%d&amp;quot;,i)&lt;br /&gt;
 until i==3&lt;br /&gt;
&lt;br /&gt;
=== Numeric for ===&lt;br /&gt;
Arrays in Lua are one-based (in indices are not specified, the first one is 1, not 0).&lt;br /&gt;
 local arr = {2,3,7,5}&lt;br /&gt;
 for i=1,#arr do logf(&amp;quot;%d&amp;quot;,arr[i]) end&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;b&amp;gt;for&amp;lt;/b&amp;gt; initVar,limit,increment &amp;lt;b&amp;gt;do&amp;lt;/b&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;i&amp;gt;number assignment&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;initVar&amp;lt;/code&amp;gt; inits loop-local variable&lt;br /&gt;
* &amp;lt;i&amp;gt;number&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;limit&amp;lt;/code&amp;gt; loops until initVar reaches this value&lt;br /&gt;
* &amp;lt;i&amp;gt;optional number&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;increment&amp;lt;/code&amp;gt; after each loop initVar increment by this value (default 1)&lt;br /&gt;
&lt;br /&gt;
=== Generic for ===&lt;br /&gt;
Is rather sophisticated. Most common example (the order of elements in &amp;lt;code&amp;gt;pairs()&amp;lt;/code&amp;gt; is not guaranteed):&lt;br /&gt;
 local tab = {one=1, two=2, three=3}&lt;br /&gt;
 for key,val in pairs(tab) do logf(&amp;quot;%s:%d&amp;quot;,key,val) end&lt;br /&gt;
Generic for syntax&lt;br /&gt;
 &amp;lt;b&amp;gt;for&amp;lt;/b&amp;gt; var_1, ..., var_n &amp;lt;b&amp;gt;in&amp;lt;/b&amp;gt; explist &amp;lt;b&amp;gt;do&amp;lt;/b&amp;gt; block end&lt;br /&gt;
is equivalent to (Full explanation [https://www.lua.org/pil/7.2.html here].)&lt;br /&gt;
 do&lt;br /&gt;
   local _f, _s, _var = explist&lt;br /&gt;
   while true do&lt;br /&gt;
     local var_1, ... , var_n = _f(_s, _var)&lt;br /&gt;
     _var = var_1&lt;br /&gt;
     if _var == nil then break end&lt;br /&gt;
     block&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Iterator closure that holds its state&lt;br /&gt;
 function iter(a)&lt;br /&gt;
   local i = 0&lt;br /&gt;
   return function()&lt;br /&gt;
     i = i+1&lt;br /&gt;
     return a[i]&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 local arr = {2,3,7,5}&lt;br /&gt;
 for value in iter(arr) do&lt;br /&gt;
   logf(&amp;quot;%d&amp;quot;,value)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Stateless iterator (in this case returns variable list: key and value)&lt;br /&gt;
 function iter(a,i)&lt;br /&gt;
   i = i+1&lt;br /&gt;
   if a[i] then return i,a[i] end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 local arr = {2,3,7,5}&lt;br /&gt;
 for k,v in iter,arr,0 do&lt;br /&gt;
   logf(&amp;quot;%d:%d&amp;quot;,k,v)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Same effect using &amp;lt;code&amp;gt;ipairs()&amp;lt;/code&amp;gt; Lua function (without initial state)&lt;br /&gt;
 for k,v in ipairs(arr) do&lt;br /&gt;
   logf(&amp;quot;%d:%d&amp;quot;,k,v)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Now return to the most common example above using &amp;lt;code&amp;gt;pairs()&amp;lt;/code&amp;gt; Lua function and read about &amp;lt;code&amp;gt;pairs()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;ipairs()&amp;lt;/code&amp;gt; implementation [https://www.lua.org/pil/7.3.html here].&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
&lt;br /&gt;
Lua allows multiple results (comma separated):&lt;br /&gt;
&lt;br /&gt;
 function diskSpace()&lt;br /&gt;
   return devices.system.freeSpace, devices.system.totalSpace&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 logf(&amp;quot;Free space: %d MB&amp;quot;, diskSpace()) -- only first return value is used&lt;br /&gt;
 local free,total = diskSpace() -- values are stored into LHS var-list&lt;br /&gt;
 logf(&amp;quot;Free space: %d %%&amp;quot;, 100*free/total)&lt;br /&gt;
&lt;br /&gt;
Variable-length arguments are also available:&lt;br /&gt;
&lt;br /&gt;
 function sum(...)&lt;br /&gt;
   local result = 0&lt;br /&gt;
   for _,v in ipairs(arg) do&lt;br /&gt;
     result = result + v&lt;br /&gt;
   end&lt;br /&gt;
   return result&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 logf(&amp;quot;Sum: %d&amp;quot;, sum(2,3,5))&lt;/div&gt;</summary>
		<author><name>Jturon</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=NETIO_Lua_Manual&amp;diff=325</id>
		<title>NETIO Lua Manual</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=NETIO_Lua_Manual&amp;diff=325"/>
		<updated>2017-04-26T09:45:34Z</updated>

		<summary type="html">&lt;p&gt;Jturon: /* Functions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Debugging ==&lt;br /&gt;
To debug your code, use [[Function log()|log()]] and [[Function logf()|logf()]] functions. See the output in system events log.&lt;br /&gt;
&lt;br /&gt;
== Data types ==&lt;br /&gt;
Lua supports these data types:&lt;br /&gt;
* &amp;lt;i&amp;gt;nil&amp;lt;/i&amp;gt; (to assign &amp;lt;i&amp;gt;nil&amp;lt;/i&amp;gt; value effectively deletes the variable)&lt;br /&gt;
* &amp;lt;i&amp;gt;boolean&amp;lt;/i&amp;gt; (falsy values are &amp;lt;i&amp;gt;nil&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;false&amp;lt;/i&amp;gt; only; &amp;quot;&amp;quot; and 0 evaluates as &amp;lt;i&amp;gt;true&amp;lt;/i&amp;gt;)&lt;br /&gt;
* &amp;lt;i&amp;gt;number&amp;lt;/i&amp;gt; (decimals only in standard Lua, integers only in Netio Lua)&lt;br /&gt;
* &amp;lt;i&amp;gt;string&amp;lt;/i&amp;gt; (same strings share same address, so equality operator measures both address and value)&lt;br /&gt;
* &amp;lt;i&amp;gt;tables&amp;lt;/i&amp;gt; are associative arrays. (Tables with numeric indices are, well, just arrays.)&lt;br /&gt;
&lt;br /&gt;
 local numbers = {2,3,7,5} -- array (first index = 1)&lt;br /&gt;
 local dictionary = {one=1, two=2, three=3} -- table&lt;br /&gt;
 local numbersZeroBased = {[0]=2,3,7,5} -- array (first index = 0)&lt;br /&gt;
&lt;br /&gt;
== Operators ==&lt;br /&gt;
Lua has its own manners:&lt;br /&gt;
* &amp;lt;code&amp;gt;~=&amp;lt;/code&amp;gt; is inequality operator&lt;br /&gt;
* &amp;lt;code&amp;gt;..&amp;lt;/code&amp;gt; is string concatenation (don't use plus)&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;s&amp;gt;i++&amp;lt;/s&amp;gt;&amp;lt;/code&amp;gt; no increment/decrement operator &amp;lt;code&amp;gt;i = i + 1&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;s&amp;gt;max = a&amp;lt;b ? b : a&amp;lt;/s&amp;gt;&amp;lt;/code&amp;gt; no ternary operator. Use (and get used to) &amp;lt;i&amp;gt;and idiom&amp;lt;/i&amp;gt; instead: &amp;lt;code&amp;gt;max = (a&amp;lt;b) and b or a&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;i&amp;gt;or idiom&amp;lt;/i&amp;gt; works: &amp;lt;code&amp;gt;x = x or 42&amp;lt;/code&amp;gt; is equivalent to &amp;lt;code&amp;gt;if not x then x = 42 end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Conditions ==&lt;br /&gt;
Lua conditions has casual syntax, see [https://www.lua.org/pil/4.3.1.html here]. Just keep in mind to merge &amp;lt;code&amp;gt;else&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;elseif&amp;lt;/code&amp;gt; or multiple &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt;s are required.&lt;br /&gt;
&lt;br /&gt;
Note that falsy values are &amp;lt;i&amp;gt;nil&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;false&amp;lt;/i&amp;gt; only. Empty string and 0 evaluates as true. If you come from C, you might be surprised by following snippet:&lt;br /&gt;
&lt;br /&gt;
 if devices.system.output1_consumption then&lt;br /&gt;
   -- always happens, even if the consumption is 0&lt;br /&gt;
   log(&amp;quot;Outlet 1 supplies power&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 if not devices.system.output1_consumption then&lt;br /&gt;
   -- never happens, even if the consumption is 0&lt;br /&gt;
   log(&amp;quot;Outlet 1 is idle&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
== Loops ==&lt;br /&gt;
Lua has &amp;lt;code&amp;gt;break&amp;lt;/code&amp;gt; statement, but no &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt; (use condition inside loop instead).&lt;br /&gt;
=== While ===&lt;br /&gt;
While syntax is not different to other languages:&lt;br /&gt;
 local i = 0&lt;br /&gt;
 while i~=3 do&lt;br /&gt;
   i = i + 1&lt;br /&gt;
   logf(&amp;quot;%d&amp;quot;,i)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
=== Repeat until ===&lt;br /&gt;
Repeat until syntax is the same as Pascal's, other languages have similar do-while loops:&lt;br /&gt;
 local i = 0&lt;br /&gt;
 repeat&lt;br /&gt;
   i = i + 1&lt;br /&gt;
   logf(&amp;quot;%d&amp;quot;,i)&lt;br /&gt;
 until i==3&lt;br /&gt;
&lt;br /&gt;
=== Numeric for ===&lt;br /&gt;
Arrays in Lua are one-based (in indices are not specified, the first one is 1, not 0).&lt;br /&gt;
 local arr = {2,3,7,5}&lt;br /&gt;
 for i=1,#arr do logf(&amp;quot;%d&amp;quot;,arr[i]) end&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;b&amp;gt;for&amp;lt;/b&amp;gt; initVar,limit,increment &amp;lt;b&amp;gt;do&amp;lt;/b&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;i&amp;gt;number assignment&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;initVar&amp;lt;/code&amp;gt; inits loop-local variable&lt;br /&gt;
* &amp;lt;i&amp;gt;number&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;limit&amp;lt;/code&amp;gt; loops until initVar reaches this value&lt;br /&gt;
* &amp;lt;i&amp;gt;optional number&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;increment&amp;lt;/code&amp;gt; after each loop initVar increment by this value (default 1)&lt;br /&gt;
&lt;br /&gt;
=== Generic for ===&lt;br /&gt;
Is rather sophisticated. Most common example (the order of elements in &amp;lt;code&amp;gt;pairs()&amp;lt;/code&amp;gt; is not guaranteed):&lt;br /&gt;
 local tab = {one=1, two=2, three=3}&lt;br /&gt;
 for key,val in pairs(tab) do logf(&amp;quot;%s:%d&amp;quot;,key,val) end&lt;br /&gt;
Generic for syntax&lt;br /&gt;
 &amp;lt;b&amp;gt;for&amp;lt;/b&amp;gt; var_1, ..., var_n &amp;lt;b&amp;gt;in&amp;lt;/b&amp;gt; explist &amp;lt;b&amp;gt;do&amp;lt;/b&amp;gt; block end&lt;br /&gt;
is equivalent to (Full explanation [https://www.lua.org/pil/7.2.html here].)&lt;br /&gt;
 do&lt;br /&gt;
   local _f, _s, _var = explist&lt;br /&gt;
   while true do&lt;br /&gt;
     local var_1, ... , var_n = _f(_s, _var)&lt;br /&gt;
     _var = var_1&lt;br /&gt;
     if _var == nil then break end&lt;br /&gt;
     block&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Iterator closure that holds its state&lt;br /&gt;
 function iter(a)&lt;br /&gt;
   local i = 0&lt;br /&gt;
   return function()&lt;br /&gt;
     i = i+1&lt;br /&gt;
     return a[i]&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 local arr = {2,3,7,5}&lt;br /&gt;
 for value in iter(arr) do&lt;br /&gt;
   logf(&amp;quot;%d&amp;quot;,value)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Stateless iterator (in this case returns variable list: key and value)&lt;br /&gt;
 function iter(a,i)&lt;br /&gt;
   i = i+1&lt;br /&gt;
   if a[i] then return i,a[i] end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 local arr = {2,3,7,5}&lt;br /&gt;
 for k,v in iter,arr,0 do&lt;br /&gt;
   logf(&amp;quot;%d:%d&amp;quot;,k,v)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Same effect using &amp;lt;code&amp;gt;ipairs()&amp;lt;/code&amp;gt; Lua function (without initial state)&lt;br /&gt;
 for k,v in ipairs(arr) do&lt;br /&gt;
   logf(&amp;quot;%d:%d&amp;quot;,k,v)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Now return to the most common example above using &amp;lt;code&amp;gt;pairs()&amp;lt;/code&amp;gt; Lua function and read about &amp;lt;code&amp;gt;pairs()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;ipairs()&amp;lt;/code&amp;gt; implementation [https://www.lua.org/pil/7.3.html here].&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
&lt;br /&gt;
Lua allows multiple results (comma separated):&lt;br /&gt;
&lt;br /&gt;
 function diskSpace()&lt;br /&gt;
   return devices.system.freeSpace, devices.system.totalSpace&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 logf(&amp;quot;Free space: %d MB&amp;quot;, diskSpace()) -- only first return value is used&lt;br /&gt;
 local free,total = diskSpace() -- values are stored into LHS var-list&lt;br /&gt;
 logf(&amp;quot;Free space: %d %%&amp;quot;, 100*free/total)&lt;br /&gt;
&lt;br /&gt;
Variable-length arguments are also available:&lt;br /&gt;
&lt;br /&gt;
 function sum(...)&lt;br /&gt;
   local result = 0&lt;br /&gt;
   for _,v in ipairs(arg) do&lt;br /&gt;
     result = result + v&lt;br /&gt;
   end&lt;br /&gt;
   return result&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 logf(&amp;quot;Sum: %d&amp;quot;, sum(2,3,5))&lt;/div&gt;</summary>
		<author><name>Jturon</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=NETIO_Lua_Manual&amp;diff=324</id>
		<title>NETIO Lua Manual</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=NETIO_Lua_Manual&amp;diff=324"/>
		<updated>2017-04-26T09:42:14Z</updated>

		<summary type="html">&lt;p&gt;Jturon: /* Conditions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Debugging ==&lt;br /&gt;
To debug your code, use [[Function log()|log()]] and [[Function logf()|logf()]] functions. See the output in system events log.&lt;br /&gt;
&lt;br /&gt;
== Data types ==&lt;br /&gt;
Lua supports these data types:&lt;br /&gt;
* &amp;lt;i&amp;gt;nil&amp;lt;/i&amp;gt; (to assign &amp;lt;i&amp;gt;nil&amp;lt;/i&amp;gt; value effectively deletes the variable)&lt;br /&gt;
* &amp;lt;i&amp;gt;boolean&amp;lt;/i&amp;gt; (falsy values are &amp;lt;i&amp;gt;nil&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;false&amp;lt;/i&amp;gt; only; &amp;quot;&amp;quot; and 0 evaluates as &amp;lt;i&amp;gt;true&amp;lt;/i&amp;gt;)&lt;br /&gt;
* &amp;lt;i&amp;gt;number&amp;lt;/i&amp;gt; (decimals only in standard Lua, integers only in Netio Lua)&lt;br /&gt;
* &amp;lt;i&amp;gt;string&amp;lt;/i&amp;gt; (same strings share same address, so equality operator measures both address and value)&lt;br /&gt;
* &amp;lt;i&amp;gt;tables&amp;lt;/i&amp;gt; are associative arrays. (Tables with numeric indices are, well, just arrays.)&lt;br /&gt;
&lt;br /&gt;
 local numbers = {2,3,7,5} -- array (first index = 1)&lt;br /&gt;
 local dictionary = {one=1, two=2, three=3} -- table&lt;br /&gt;
 local numbersZeroBased = {[0]=2,3,7,5} -- array (first index = 0)&lt;br /&gt;
&lt;br /&gt;
== Operators ==&lt;br /&gt;
Lua has its own manners:&lt;br /&gt;
* &amp;lt;code&amp;gt;~=&amp;lt;/code&amp;gt; is inequality operator&lt;br /&gt;
* &amp;lt;code&amp;gt;..&amp;lt;/code&amp;gt; is string concatenation (don't use plus)&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;s&amp;gt;i++&amp;lt;/s&amp;gt;&amp;lt;/code&amp;gt; no increment/decrement operator &amp;lt;code&amp;gt;i = i + 1&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;s&amp;gt;max = a&amp;lt;b ? b : a&amp;lt;/s&amp;gt;&amp;lt;/code&amp;gt; no ternary operator. Use (and get used to) &amp;lt;i&amp;gt;and idiom&amp;lt;/i&amp;gt; instead: &amp;lt;code&amp;gt;max = (a&amp;lt;b) and b or a&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;i&amp;gt;or idiom&amp;lt;/i&amp;gt; works: &amp;lt;code&amp;gt;x = x or 42&amp;lt;/code&amp;gt; is equivalent to &amp;lt;code&amp;gt;if not x then x = 42 end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Conditions ==&lt;br /&gt;
Lua conditions has casual syntax, see [https://www.lua.org/pil/4.3.1.html here]. Just keep in mind to merge &amp;lt;code&amp;gt;else&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;elseif&amp;lt;/code&amp;gt; or multiple &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt;s are required.&lt;br /&gt;
&lt;br /&gt;
Note that falsy values are &amp;lt;i&amp;gt;nil&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;false&amp;lt;/i&amp;gt; only. Empty string and 0 evaluates as true. If you come from C, you might be surprised by following snippet:&lt;br /&gt;
&lt;br /&gt;
 if devices.system.output1_consumption then&lt;br /&gt;
   -- always happens, even if the consumption is 0&lt;br /&gt;
   log(&amp;quot;Outlet 1 supplies power&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 if not devices.system.output1_consumption then&lt;br /&gt;
   -- never happens, even if the consumption is 0&lt;br /&gt;
   log(&amp;quot;Outlet 1 is idle&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
== Loops ==&lt;br /&gt;
Lua has &amp;lt;code&amp;gt;break&amp;lt;/code&amp;gt; statement, but no &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt; (use condition inside loop instead).&lt;br /&gt;
=== While ===&lt;br /&gt;
While syntax is not different to other languages:&lt;br /&gt;
 local i = 0&lt;br /&gt;
 while i~=3 do&lt;br /&gt;
   i = i + 1&lt;br /&gt;
   logf(&amp;quot;%d&amp;quot;,i)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
=== Repeat until ===&lt;br /&gt;
Repeat until syntax is the same as Pascal's, other languages have similar do-while loops:&lt;br /&gt;
 local i = 0&lt;br /&gt;
 repeat&lt;br /&gt;
   i = i + 1&lt;br /&gt;
   logf(&amp;quot;%d&amp;quot;,i)&lt;br /&gt;
 until i==3&lt;br /&gt;
&lt;br /&gt;
=== Numeric for ===&lt;br /&gt;
Arrays in Lua are one-based (in indices are not specified, the first one is 1, not 0).&lt;br /&gt;
 local arr = {2,3,7,5}&lt;br /&gt;
 for i=1,#arr do logf(&amp;quot;%d&amp;quot;,arr[i]) end&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;b&amp;gt;for&amp;lt;/b&amp;gt; initVar,limit,increment &amp;lt;b&amp;gt;do&amp;lt;/b&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;i&amp;gt;number assignment&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;initVar&amp;lt;/code&amp;gt; inits loop-local variable&lt;br /&gt;
* &amp;lt;i&amp;gt;number&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;limit&amp;lt;/code&amp;gt; loops until initVar reaches this value&lt;br /&gt;
* &amp;lt;i&amp;gt;optional number&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;increment&amp;lt;/code&amp;gt; after each loop initVar increment by this value (default 1)&lt;br /&gt;
&lt;br /&gt;
=== Generic for ===&lt;br /&gt;
Is rather sophisticated. Most common example (the order of elements in &amp;lt;code&amp;gt;pairs()&amp;lt;/code&amp;gt; is not guaranteed):&lt;br /&gt;
 local tab = {one=1, two=2, three=3}&lt;br /&gt;
 for key,val in pairs(tab) do logf(&amp;quot;%s:%d&amp;quot;,key,val) end&lt;br /&gt;
Generic for syntax&lt;br /&gt;
 &amp;lt;b&amp;gt;for&amp;lt;/b&amp;gt; var_1, ..., var_n &amp;lt;b&amp;gt;in&amp;lt;/b&amp;gt; explist &amp;lt;b&amp;gt;do&amp;lt;/b&amp;gt; block end&lt;br /&gt;
is equivalent to (Full explanation [https://www.lua.org/pil/7.2.html here].)&lt;br /&gt;
 do&lt;br /&gt;
   local _f, _s, _var = explist&lt;br /&gt;
   while true do&lt;br /&gt;
     local var_1, ... , var_n = _f(_s, _var)&lt;br /&gt;
     _var = var_1&lt;br /&gt;
     if _var == nil then break end&lt;br /&gt;
     block&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Iterator closure that holds its state&lt;br /&gt;
 function iter(a)&lt;br /&gt;
   local i = 0&lt;br /&gt;
   return function()&lt;br /&gt;
     i = i+1&lt;br /&gt;
     return a[i]&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 local arr = {2,3,7,5}&lt;br /&gt;
 for value in iter(arr) do&lt;br /&gt;
   logf(&amp;quot;%d&amp;quot;,value)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Stateless iterator (in this case returns variable list: key and value)&lt;br /&gt;
 function iter(a,i)&lt;br /&gt;
   i = i+1&lt;br /&gt;
   if a[i] then return i,a[i] end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 local arr = {2,3,7,5}&lt;br /&gt;
 for k,v in iter,arr,0 do&lt;br /&gt;
   logf(&amp;quot;%d:%d&amp;quot;,k,v)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Same effect using &amp;lt;code&amp;gt;ipairs()&amp;lt;/code&amp;gt; Lua function (without initial state)&lt;br /&gt;
 for k,v in ipairs(arr) do&lt;br /&gt;
   logf(&amp;quot;%d:%d&amp;quot;,k,v)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Now return to the most common example above using &amp;lt;code&amp;gt;pairs()&amp;lt;/code&amp;gt; Lua function and read about &amp;lt;code&amp;gt;pairs()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;ipairs()&amp;lt;/code&amp;gt; implementation [https://www.lua.org/pil/7.3.html here].&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
&lt;br /&gt;
Lua allows multiple results (comma separated):&lt;br /&gt;
&lt;br /&gt;
 function diskSpace()&lt;br /&gt;
   return devices.system.freeSpace, devices.system.totalSpace&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 logf(&amp;quot;Free space: %d MB&amp;quot;, diskSpace())&lt;br /&gt;
 local free,total = diskSpace()&lt;br /&gt;
 logf(&amp;quot;Free space: %d %%&amp;quot;, 100*free/total)&lt;br /&gt;
&lt;br /&gt;
Variable-length arguments are also available:&lt;br /&gt;
&lt;br /&gt;
 function sum(...)&lt;br /&gt;
   local result = 0&lt;br /&gt;
   for _,v in ipairs(arg) do&lt;br /&gt;
     result = result + v&lt;br /&gt;
   end&lt;br /&gt;
   return result&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 logf(&amp;quot;Sum: %d&amp;quot;, sum(2,3,5))&lt;/div&gt;</summary>
		<author><name>Jturon</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=NETIO_Lua_Manual&amp;diff=323</id>
		<title>NETIO Lua Manual</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=NETIO_Lua_Manual&amp;diff=323"/>
		<updated>2017-04-26T09:40:10Z</updated>

		<summary type="html">&lt;p&gt;Jturon: /* Operators */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Debugging ==&lt;br /&gt;
To debug your code, use [[Function log()|log()]] and [[Function logf()|logf()]] functions. See the output in system events log.&lt;br /&gt;
&lt;br /&gt;
== Data types ==&lt;br /&gt;
Lua supports these data types:&lt;br /&gt;
* &amp;lt;i&amp;gt;nil&amp;lt;/i&amp;gt; (to assign &amp;lt;i&amp;gt;nil&amp;lt;/i&amp;gt; value effectively deletes the variable)&lt;br /&gt;
* &amp;lt;i&amp;gt;boolean&amp;lt;/i&amp;gt; (falsy values are &amp;lt;i&amp;gt;nil&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;false&amp;lt;/i&amp;gt; only; &amp;quot;&amp;quot; and 0 evaluates as &amp;lt;i&amp;gt;true&amp;lt;/i&amp;gt;)&lt;br /&gt;
* &amp;lt;i&amp;gt;number&amp;lt;/i&amp;gt; (decimals only in standard Lua, integers only in Netio Lua)&lt;br /&gt;
* &amp;lt;i&amp;gt;string&amp;lt;/i&amp;gt; (same strings share same address, so equality operator measures both address and value)&lt;br /&gt;
* &amp;lt;i&amp;gt;tables&amp;lt;/i&amp;gt; are associative arrays. (Tables with numeric indices are, well, just arrays.)&lt;br /&gt;
&lt;br /&gt;
 local numbers = {2,3,7,5} -- array (first index = 1)&lt;br /&gt;
 local dictionary = {one=1, two=2, three=3} -- table&lt;br /&gt;
 local numbersZeroBased = {[0]=2,3,7,5} -- array (first index = 0)&lt;br /&gt;
&lt;br /&gt;
== Operators ==&lt;br /&gt;
Lua has its own manners:&lt;br /&gt;
* &amp;lt;code&amp;gt;~=&amp;lt;/code&amp;gt; is inequality operator&lt;br /&gt;
* &amp;lt;code&amp;gt;..&amp;lt;/code&amp;gt; is string concatenation (don't use plus)&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;s&amp;gt;i++&amp;lt;/s&amp;gt;&amp;lt;/code&amp;gt; no increment/decrement operator &amp;lt;code&amp;gt;i = i + 1&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;s&amp;gt;max = a&amp;lt;b ? b : a&amp;lt;/s&amp;gt;&amp;lt;/code&amp;gt; no ternary operator. Use (and get used to) &amp;lt;i&amp;gt;and idiom&amp;lt;/i&amp;gt; instead: &amp;lt;code&amp;gt;max = (a&amp;lt;b) and b or a&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;i&amp;gt;or idiom&amp;lt;/i&amp;gt; works: &amp;lt;code&amp;gt;x = x or 42&amp;lt;/code&amp;gt; is equivalent to &amp;lt;code&amp;gt;if not x then x = 42 end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Conditions ==&lt;br /&gt;
Lua conditions has casual syntax, see [https://www.lua.org/pil/4.3.1.html here]. Just keep in mind to merge &amp;lt;code&amp;gt;else&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;elseif&amp;lt;/code&amp;gt; or multiple &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt;s are required.&lt;br /&gt;
&lt;br /&gt;
Note that falsy values are &amp;lt;i&amp;gt;nil&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;false&amp;lt;/i&amp;gt; only. Empty string and 0 evaluates as true. If you come from C, you might be surprised by following snippet:&lt;br /&gt;
&lt;br /&gt;
 if devices.system.output1_consumption then&lt;br /&gt;
   -- always happens, even if the consumption is 0&lt;br /&gt;
   log(&amp;quot;Outlet 1 is on&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 if not devices.system.output1_consumption then&lt;br /&gt;
   -- never happens, even if the consumption is 0&lt;br /&gt;
   log(&amp;quot;Outlet 1 is off&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
== Loops ==&lt;br /&gt;
Lua has &amp;lt;code&amp;gt;break&amp;lt;/code&amp;gt; statement, but no &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt; (use condition inside loop instead).&lt;br /&gt;
=== While ===&lt;br /&gt;
While syntax is not different to other languages:&lt;br /&gt;
 local i = 0&lt;br /&gt;
 while i~=3 do&lt;br /&gt;
   i = i + 1&lt;br /&gt;
   logf(&amp;quot;%d&amp;quot;,i)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
=== Repeat until ===&lt;br /&gt;
Repeat until syntax is the same as Pascal's, other languages have similar do-while loops:&lt;br /&gt;
 local i = 0&lt;br /&gt;
 repeat&lt;br /&gt;
   i = i + 1&lt;br /&gt;
   logf(&amp;quot;%d&amp;quot;,i)&lt;br /&gt;
 until i==3&lt;br /&gt;
&lt;br /&gt;
=== Numeric for ===&lt;br /&gt;
Arrays in Lua are one-based (in indices are not specified, the first one is 1, not 0).&lt;br /&gt;
 local arr = {2,3,7,5}&lt;br /&gt;
 for i=1,#arr do logf(&amp;quot;%d&amp;quot;,arr[i]) end&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;b&amp;gt;for&amp;lt;/b&amp;gt; initVar,limit,increment &amp;lt;b&amp;gt;do&amp;lt;/b&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;i&amp;gt;number assignment&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;initVar&amp;lt;/code&amp;gt; inits loop-local variable&lt;br /&gt;
* &amp;lt;i&amp;gt;number&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;limit&amp;lt;/code&amp;gt; loops until initVar reaches this value&lt;br /&gt;
* &amp;lt;i&amp;gt;optional number&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;increment&amp;lt;/code&amp;gt; after each loop initVar increment by this value (default 1)&lt;br /&gt;
&lt;br /&gt;
=== Generic for ===&lt;br /&gt;
Is rather sophisticated. Most common example (the order of elements in &amp;lt;code&amp;gt;pairs()&amp;lt;/code&amp;gt; is not guaranteed):&lt;br /&gt;
 local tab = {one=1, two=2, three=3}&lt;br /&gt;
 for key,val in pairs(tab) do logf(&amp;quot;%s:%d&amp;quot;,key,val) end&lt;br /&gt;
Generic for syntax&lt;br /&gt;
 &amp;lt;b&amp;gt;for&amp;lt;/b&amp;gt; var_1, ..., var_n &amp;lt;b&amp;gt;in&amp;lt;/b&amp;gt; explist &amp;lt;b&amp;gt;do&amp;lt;/b&amp;gt; block end&lt;br /&gt;
is equivalent to (Full explanation [https://www.lua.org/pil/7.2.html here].)&lt;br /&gt;
 do&lt;br /&gt;
   local _f, _s, _var = explist&lt;br /&gt;
   while true do&lt;br /&gt;
     local var_1, ... , var_n = _f(_s, _var)&lt;br /&gt;
     _var = var_1&lt;br /&gt;
     if _var == nil then break end&lt;br /&gt;
     block&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Iterator closure that holds its state&lt;br /&gt;
 function iter(a)&lt;br /&gt;
   local i = 0&lt;br /&gt;
   return function()&lt;br /&gt;
     i = i+1&lt;br /&gt;
     return a[i]&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 local arr = {2,3,7,5}&lt;br /&gt;
 for value in iter(arr) do&lt;br /&gt;
   logf(&amp;quot;%d&amp;quot;,value)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Stateless iterator (in this case returns variable list: key and value)&lt;br /&gt;
 function iter(a,i)&lt;br /&gt;
   i = i+1&lt;br /&gt;
   if a[i] then return i,a[i] end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 local arr = {2,3,7,5}&lt;br /&gt;
 for k,v in iter,arr,0 do&lt;br /&gt;
   logf(&amp;quot;%d:%d&amp;quot;,k,v)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Same effect using &amp;lt;code&amp;gt;ipairs()&amp;lt;/code&amp;gt; Lua function (without initial state)&lt;br /&gt;
 for k,v in ipairs(arr) do&lt;br /&gt;
   logf(&amp;quot;%d:%d&amp;quot;,k,v)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Now return to the most common example above using &amp;lt;code&amp;gt;pairs()&amp;lt;/code&amp;gt; Lua function and read about &amp;lt;code&amp;gt;pairs()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;ipairs()&amp;lt;/code&amp;gt; implementation [https://www.lua.org/pil/7.3.html here].&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
&lt;br /&gt;
Lua allows multiple results (comma separated):&lt;br /&gt;
&lt;br /&gt;
 function diskSpace()&lt;br /&gt;
   return devices.system.freeSpace, devices.system.totalSpace&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 logf(&amp;quot;Free space: %d MB&amp;quot;, diskSpace())&lt;br /&gt;
 local free,total = diskSpace()&lt;br /&gt;
 logf(&amp;quot;Free space: %d %%&amp;quot;, 100*free/total)&lt;br /&gt;
&lt;br /&gt;
Variable-length arguments are also available:&lt;br /&gt;
&lt;br /&gt;
 function sum(...)&lt;br /&gt;
   local result = 0&lt;br /&gt;
   for _,v in ipairs(arg) do&lt;br /&gt;
     result = result + v&lt;br /&gt;
   end&lt;br /&gt;
   return result&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 logf(&amp;quot;Sum: %d&amp;quot;, sum(2,3,5))&lt;/div&gt;</summary>
		<author><name>Jturon</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=NETIO_Lua_Manual&amp;diff=322</id>
		<title>NETIO Lua Manual</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=NETIO_Lua_Manual&amp;diff=322"/>
		<updated>2017-04-25T11:35:29Z</updated>

		<summary type="html">&lt;p&gt;Jturon: /* Data types */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Debugging ==&lt;br /&gt;
To debug your code, use [[Function log()|log()]] and [[Function logf()|logf()]] functions. See the output in system events log.&lt;br /&gt;
&lt;br /&gt;
== Data types ==&lt;br /&gt;
Lua supports these data types:&lt;br /&gt;
* &amp;lt;i&amp;gt;nil&amp;lt;/i&amp;gt; (to assign &amp;lt;i&amp;gt;nil&amp;lt;/i&amp;gt; value effectively deletes the variable)&lt;br /&gt;
* &amp;lt;i&amp;gt;boolean&amp;lt;/i&amp;gt; (falsy values are &amp;lt;i&amp;gt;nil&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;false&amp;lt;/i&amp;gt; only; &amp;quot;&amp;quot; and 0 evaluates as &amp;lt;i&amp;gt;true&amp;lt;/i&amp;gt;)&lt;br /&gt;
* &amp;lt;i&amp;gt;number&amp;lt;/i&amp;gt; (decimals only in standard Lua, integers only in Netio Lua)&lt;br /&gt;
* &amp;lt;i&amp;gt;string&amp;lt;/i&amp;gt; (same strings share same address, so equality operator measures both address and value)&lt;br /&gt;
* &amp;lt;i&amp;gt;tables&amp;lt;/i&amp;gt; are associative arrays. (Tables with numeric indices are, well, just arrays.)&lt;br /&gt;
&lt;br /&gt;
 local numbers = {2,3,7,5} -- array (first index = 1)&lt;br /&gt;
 local dictionary = {one=1, two=2, three=3} -- table&lt;br /&gt;
 local numbersZeroBased = {[0]=2,3,7,5} -- array (first index = 0)&lt;br /&gt;
&lt;br /&gt;
== Operators ==&lt;br /&gt;
Lua has its own manners:&lt;br /&gt;
* &amp;lt;code&amp;gt;~=&amp;lt;/code&amp;gt; is inequality operator&lt;br /&gt;
* &amp;lt;code&amp;gt;..&amp;lt;/code&amp;gt; is string concatenation (don't use plus)&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;s&amp;gt;i++&amp;lt;/s&amp;gt;&amp;lt;/code&amp;gt; no increment/decrement operator &amp;lt;code&amp;gt;i = i + 1&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;s&amp;gt;max = a&amp;lt;b ? b : a&amp;lt;/s&amp;gt;&amp;lt;/code&amp;gt; no ternary operator. Use (and get used to) and idiom instead: &amp;lt;code&amp;gt;max = (a&amp;lt;b) and b or a&amp;lt;/code&amp;gt;&lt;br /&gt;
* or idiom works: &amp;lt;code&amp;gt;x = x or 42&amp;lt;/code&amp;gt; is equivalent to &amp;lt;code&amp;gt;if not x then x = 42 end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Conditions ==&lt;br /&gt;
Lua conditions has casual syntax, see [https://www.lua.org/pil/4.3.1.html here]. Just keep in mind to merge &amp;lt;code&amp;gt;else&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;elseif&amp;lt;/code&amp;gt; or multiple &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt;s are required.&lt;br /&gt;
&lt;br /&gt;
Note that falsy values are &amp;lt;i&amp;gt;nil&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;false&amp;lt;/i&amp;gt; only. Empty string and 0 evaluates as true. If you come from C, you might be surprised by following snippet:&lt;br /&gt;
&lt;br /&gt;
 if devices.system.output1_consumption then&lt;br /&gt;
   -- always happens, even if the consumption is 0&lt;br /&gt;
   log(&amp;quot;Outlet 1 is on&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 if not devices.system.output1_consumption then&lt;br /&gt;
   -- never happens, even if the consumption is 0&lt;br /&gt;
   log(&amp;quot;Outlet 1 is off&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
== Loops ==&lt;br /&gt;
Lua has &amp;lt;code&amp;gt;break&amp;lt;/code&amp;gt; statement, but no &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt; (use condition inside loop instead).&lt;br /&gt;
=== While ===&lt;br /&gt;
While syntax is not different to other languages:&lt;br /&gt;
 local i = 0&lt;br /&gt;
 while i~=3 do&lt;br /&gt;
   i = i + 1&lt;br /&gt;
   logf(&amp;quot;%d&amp;quot;,i)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
=== Repeat until ===&lt;br /&gt;
Repeat until syntax is the same as Pascal's, other languages have similar do-while loops:&lt;br /&gt;
 local i = 0&lt;br /&gt;
 repeat&lt;br /&gt;
   i = i + 1&lt;br /&gt;
   logf(&amp;quot;%d&amp;quot;,i)&lt;br /&gt;
 until i==3&lt;br /&gt;
&lt;br /&gt;
=== Numeric for ===&lt;br /&gt;
Arrays in Lua are one-based (in indices are not specified, the first one is 1, not 0).&lt;br /&gt;
 local arr = {2,3,7,5}&lt;br /&gt;
 for i=1,#arr do logf(&amp;quot;%d&amp;quot;,arr[i]) end&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;b&amp;gt;for&amp;lt;/b&amp;gt; initVar,limit,increment &amp;lt;b&amp;gt;do&amp;lt;/b&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;i&amp;gt;number assignment&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;initVar&amp;lt;/code&amp;gt; inits loop-local variable&lt;br /&gt;
* &amp;lt;i&amp;gt;number&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;limit&amp;lt;/code&amp;gt; loops until initVar reaches this value&lt;br /&gt;
* &amp;lt;i&amp;gt;optional number&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;increment&amp;lt;/code&amp;gt; after each loop initVar increment by this value (default 1)&lt;br /&gt;
&lt;br /&gt;
=== Generic for ===&lt;br /&gt;
Is rather sophisticated. Most common example (the order of elements in &amp;lt;code&amp;gt;pairs()&amp;lt;/code&amp;gt; is not guaranteed):&lt;br /&gt;
 local tab = {one=1, two=2, three=3}&lt;br /&gt;
 for key,val in pairs(tab) do logf(&amp;quot;%s:%d&amp;quot;,key,val) end&lt;br /&gt;
Generic for syntax&lt;br /&gt;
 &amp;lt;b&amp;gt;for&amp;lt;/b&amp;gt; var_1, ..., var_n &amp;lt;b&amp;gt;in&amp;lt;/b&amp;gt; explist &amp;lt;b&amp;gt;do&amp;lt;/b&amp;gt; block end&lt;br /&gt;
is equivalent to (Full explanation [https://www.lua.org/pil/7.2.html here].)&lt;br /&gt;
 do&lt;br /&gt;
   local _f, _s, _var = explist&lt;br /&gt;
   while true do&lt;br /&gt;
     local var_1, ... , var_n = _f(_s, _var)&lt;br /&gt;
     _var = var_1&lt;br /&gt;
     if _var == nil then break end&lt;br /&gt;
     block&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Iterator closure that holds its state&lt;br /&gt;
 function iter(a)&lt;br /&gt;
   local i = 0&lt;br /&gt;
   return function()&lt;br /&gt;
     i = i+1&lt;br /&gt;
     return a[i]&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 local arr = {2,3,7,5}&lt;br /&gt;
 for value in iter(arr) do&lt;br /&gt;
   logf(&amp;quot;%d&amp;quot;,value)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Stateless iterator (in this case returns variable list: key and value)&lt;br /&gt;
 function iter(a,i)&lt;br /&gt;
   i = i+1&lt;br /&gt;
   if a[i] then return i,a[i] end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 local arr = {2,3,7,5}&lt;br /&gt;
 for k,v in iter,arr,0 do&lt;br /&gt;
   logf(&amp;quot;%d:%d&amp;quot;,k,v)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Same effect using &amp;lt;code&amp;gt;ipairs()&amp;lt;/code&amp;gt; Lua function (without initial state)&lt;br /&gt;
 for k,v in ipairs(arr) do&lt;br /&gt;
   logf(&amp;quot;%d:%d&amp;quot;,k,v)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Now return to the most common example above using &amp;lt;code&amp;gt;pairs()&amp;lt;/code&amp;gt; Lua function and read about &amp;lt;code&amp;gt;pairs()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;ipairs()&amp;lt;/code&amp;gt; implementation [https://www.lua.org/pil/7.3.html here].&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
&lt;br /&gt;
Lua allows multiple results (comma separated):&lt;br /&gt;
&lt;br /&gt;
 function diskSpace()&lt;br /&gt;
   return devices.system.freeSpace, devices.system.totalSpace&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 logf(&amp;quot;Free space: %d MB&amp;quot;, diskSpace())&lt;br /&gt;
 local free,total = diskSpace()&lt;br /&gt;
 logf(&amp;quot;Free space: %d %%&amp;quot;, 100*free/total)&lt;br /&gt;
&lt;br /&gt;
Variable-length arguments are also available:&lt;br /&gt;
&lt;br /&gt;
 function sum(...)&lt;br /&gt;
   local result = 0&lt;br /&gt;
   for _,v in ipairs(arg) do&lt;br /&gt;
     result = result + v&lt;br /&gt;
   end&lt;br /&gt;
   return result&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 logf(&amp;quot;Sum: %d&amp;quot;, sum(2,3,5))&lt;/div&gt;</summary>
		<author><name>Jturon</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=NETIO_Lua_Manual&amp;diff=321</id>
		<title>NETIO Lua Manual</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=NETIO_Lua_Manual&amp;diff=321"/>
		<updated>2017-04-25T11:34:36Z</updated>

		<summary type="html">&lt;p&gt;Jturon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Debugging ==&lt;br /&gt;
To debug your code, use [[Function log()|log()]] and [[Function logf()|logf()]] functions. See the output in system events log.&lt;br /&gt;
&lt;br /&gt;
== Data types ==&lt;br /&gt;
Lua supports these data types:&lt;br /&gt;
* &amp;lt;i&amp;gt;nil&amp;lt;/i&amp;gt; to assign &amp;lt;i&amp;gt;nil&amp;lt;/i&amp;gt; value effectively deletes the variable&lt;br /&gt;
* &amp;lt;i&amp;gt;boolean&amp;lt;/i&amp;gt; falsy values are &amp;lt;i&amp;gt;nil&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;false&amp;lt;/i&amp;gt; only; &amp;quot;&amp;quot; and 0 evaluates as &amp;lt;i&amp;gt;true&amp;lt;/i&amp;gt;&lt;br /&gt;
* &amp;lt;i&amp;gt;number&amp;lt;/i&amp;gt; (decimals only in standard Lua, integers only in Netio Lua)&lt;br /&gt;
* &amp;lt;i&amp;gt;string&amp;lt;/i&amp;gt; (same strings share same address, so equality operator measures both address and value)&lt;br /&gt;
* &amp;lt;i&amp;gt;tables&amp;lt;/i&amp;gt; are associative arrays. Tables with numeric indices are, well, just arrays.&lt;br /&gt;
&lt;br /&gt;
 local numbers = {2,3,7,5} -- array (first index = 1)&lt;br /&gt;
 local dictionary = {one=1, two=2, three=3} -- table&lt;br /&gt;
 local numbersZeroBased = {[0]=2,3,7,5} -- array (first index = 0)&lt;br /&gt;
&lt;br /&gt;
== Operators ==&lt;br /&gt;
Lua has its own manners:&lt;br /&gt;
* &amp;lt;code&amp;gt;~=&amp;lt;/code&amp;gt; is inequality operator&lt;br /&gt;
* &amp;lt;code&amp;gt;..&amp;lt;/code&amp;gt; is string concatenation (don't use plus)&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;s&amp;gt;i++&amp;lt;/s&amp;gt;&amp;lt;/code&amp;gt; no increment/decrement operator &amp;lt;code&amp;gt;i = i + 1&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;s&amp;gt;max = a&amp;lt;b ? b : a&amp;lt;/s&amp;gt;&amp;lt;/code&amp;gt; no ternary operator. Use (and get used to) and idiom instead: &amp;lt;code&amp;gt;max = (a&amp;lt;b) and b or a&amp;lt;/code&amp;gt;&lt;br /&gt;
* or idiom works: &amp;lt;code&amp;gt;x = x or 42&amp;lt;/code&amp;gt; is equivalent to &amp;lt;code&amp;gt;if not x then x = 42 end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Conditions ==&lt;br /&gt;
Lua conditions has casual syntax, see [https://www.lua.org/pil/4.3.1.html here]. Just keep in mind to merge &amp;lt;code&amp;gt;else&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;elseif&amp;lt;/code&amp;gt; or multiple &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt;s are required.&lt;br /&gt;
&lt;br /&gt;
Note that falsy values are &amp;lt;i&amp;gt;nil&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;false&amp;lt;/i&amp;gt; only. Empty string and 0 evaluates as true. If you come from C, you might be surprised by following snippet:&lt;br /&gt;
&lt;br /&gt;
 if devices.system.output1_consumption then&lt;br /&gt;
   -- always happens, even if the consumption is 0&lt;br /&gt;
   log(&amp;quot;Outlet 1 is on&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 if not devices.system.output1_consumption then&lt;br /&gt;
   -- never happens, even if the consumption is 0&lt;br /&gt;
   log(&amp;quot;Outlet 1 is off&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
== Loops ==&lt;br /&gt;
Lua has &amp;lt;code&amp;gt;break&amp;lt;/code&amp;gt; statement, but no &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt; (use condition inside loop instead).&lt;br /&gt;
=== While ===&lt;br /&gt;
While syntax is not different to other languages:&lt;br /&gt;
 local i = 0&lt;br /&gt;
 while i~=3 do&lt;br /&gt;
   i = i + 1&lt;br /&gt;
   logf(&amp;quot;%d&amp;quot;,i)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
=== Repeat until ===&lt;br /&gt;
Repeat until syntax is the same as Pascal's, other languages have similar do-while loops:&lt;br /&gt;
 local i = 0&lt;br /&gt;
 repeat&lt;br /&gt;
   i = i + 1&lt;br /&gt;
   logf(&amp;quot;%d&amp;quot;,i)&lt;br /&gt;
 until i==3&lt;br /&gt;
&lt;br /&gt;
=== Numeric for ===&lt;br /&gt;
Arrays in Lua are one-based (in indices are not specified, the first one is 1, not 0).&lt;br /&gt;
 local arr = {2,3,7,5}&lt;br /&gt;
 for i=1,#arr do logf(&amp;quot;%d&amp;quot;,arr[i]) end&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;b&amp;gt;for&amp;lt;/b&amp;gt; initVar,limit,increment &amp;lt;b&amp;gt;do&amp;lt;/b&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;i&amp;gt;number assignment&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;initVar&amp;lt;/code&amp;gt; inits loop-local variable&lt;br /&gt;
* &amp;lt;i&amp;gt;number&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;limit&amp;lt;/code&amp;gt; loops until initVar reaches this value&lt;br /&gt;
* &amp;lt;i&amp;gt;optional number&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;increment&amp;lt;/code&amp;gt; after each loop initVar increment by this value (default 1)&lt;br /&gt;
&lt;br /&gt;
=== Generic for ===&lt;br /&gt;
Is rather sophisticated. Most common example (the order of elements in &amp;lt;code&amp;gt;pairs()&amp;lt;/code&amp;gt; is not guaranteed):&lt;br /&gt;
 local tab = {one=1, two=2, three=3}&lt;br /&gt;
 for key,val in pairs(tab) do logf(&amp;quot;%s:%d&amp;quot;,key,val) end&lt;br /&gt;
Generic for syntax&lt;br /&gt;
 &amp;lt;b&amp;gt;for&amp;lt;/b&amp;gt; var_1, ..., var_n &amp;lt;b&amp;gt;in&amp;lt;/b&amp;gt; explist &amp;lt;b&amp;gt;do&amp;lt;/b&amp;gt; block end&lt;br /&gt;
is equivalent to (Full explanation [https://www.lua.org/pil/7.2.html here].)&lt;br /&gt;
 do&lt;br /&gt;
   local _f, _s, _var = explist&lt;br /&gt;
   while true do&lt;br /&gt;
     local var_1, ... , var_n = _f(_s, _var)&lt;br /&gt;
     _var = var_1&lt;br /&gt;
     if _var == nil then break end&lt;br /&gt;
     block&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Iterator closure that holds its state&lt;br /&gt;
 function iter(a)&lt;br /&gt;
   local i = 0&lt;br /&gt;
   return function()&lt;br /&gt;
     i = i+1&lt;br /&gt;
     return a[i]&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 local arr = {2,3,7,5}&lt;br /&gt;
 for value in iter(arr) do&lt;br /&gt;
   logf(&amp;quot;%d&amp;quot;,value)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Stateless iterator (in this case returns variable list: key and value)&lt;br /&gt;
 function iter(a,i)&lt;br /&gt;
   i = i+1&lt;br /&gt;
   if a[i] then return i,a[i] end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 local arr = {2,3,7,5}&lt;br /&gt;
 for k,v in iter,arr,0 do&lt;br /&gt;
   logf(&amp;quot;%d:%d&amp;quot;,k,v)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Same effect using &amp;lt;code&amp;gt;ipairs()&amp;lt;/code&amp;gt; Lua function (without initial state)&lt;br /&gt;
 for k,v in ipairs(arr) do&lt;br /&gt;
   logf(&amp;quot;%d:%d&amp;quot;,k,v)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Now return to the most common example above using &amp;lt;code&amp;gt;pairs()&amp;lt;/code&amp;gt; Lua function and read about &amp;lt;code&amp;gt;pairs()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;ipairs()&amp;lt;/code&amp;gt; implementation [https://www.lua.org/pil/7.3.html here].&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
&lt;br /&gt;
Lua allows multiple results (comma separated):&lt;br /&gt;
&lt;br /&gt;
 function diskSpace()&lt;br /&gt;
   return devices.system.freeSpace, devices.system.totalSpace&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 logf(&amp;quot;Free space: %d MB&amp;quot;, diskSpace())&lt;br /&gt;
 local free,total = diskSpace()&lt;br /&gt;
 logf(&amp;quot;Free space: %d %%&amp;quot;, 100*free/total)&lt;br /&gt;
&lt;br /&gt;
Variable-length arguments are also available:&lt;br /&gt;
&lt;br /&gt;
 function sum(...)&lt;br /&gt;
   local result = 0&lt;br /&gt;
   for _,v in ipairs(arg) do&lt;br /&gt;
     result = result + v&lt;br /&gt;
   end&lt;br /&gt;
   return result&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 logf(&amp;quot;Sum: %d&amp;quot;, sum(2,3,5))&lt;/div&gt;</summary>
		<author><name>Jturon</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=NETIO_Lua_Manual&amp;diff=320</id>
		<title>NETIO Lua Manual</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=NETIO_Lua_Manual&amp;diff=320"/>
		<updated>2017-04-25T11:24:57Z</updated>

		<summary type="html">&lt;p&gt;Jturon: /* Numeric for */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Debugging ==&lt;br /&gt;
To debug your code, use [[Function log()|log()]] and [[Function logf()|logf()]] functions. See the output in system events log.&lt;br /&gt;
&lt;br /&gt;
== Operators ==&lt;br /&gt;
Lua has its own manners:&lt;br /&gt;
* &amp;lt;code&amp;gt;~=&amp;lt;/code&amp;gt; is inequality operator&lt;br /&gt;
* &amp;lt;code&amp;gt;..&amp;lt;/code&amp;gt; is string concatenation (don't use plus)&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;s&amp;gt;i++&amp;lt;/s&amp;gt;&amp;lt;/code&amp;gt; no increment/decrement operator &amp;lt;code&amp;gt;i = i + 1&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;s&amp;gt;max = a&amp;lt;b ? b : a&amp;lt;/s&amp;gt;&amp;lt;/code&amp;gt; no ternary operator. Use (and get used to) and idiom instead: &amp;lt;code&amp;gt;max = (a&amp;lt;b) and b or a&amp;lt;/code&amp;gt;&lt;br /&gt;
* or idiom works: &amp;lt;code&amp;gt;x = x or 42&amp;lt;/code&amp;gt; is equivalent to &amp;lt;code&amp;gt;if not x then x = 42 end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Conditions ==&lt;br /&gt;
Lua conditions has casual syntax, see [https://www.lua.org/pil/4.3.1.html here]. Just keep in mind to merge &amp;lt;code&amp;gt;else&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;elseif&amp;lt;/code&amp;gt; or multiple &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt;s are required.&lt;br /&gt;
&lt;br /&gt;
Note that falsy values are &amp;lt;i&amp;gt;nil&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;false&amp;lt;/i&amp;gt; only. Empty string and 0 evaluates as true. If you come from C, you might be surprised by following snippet:&lt;br /&gt;
&lt;br /&gt;
 if devices.system.output1_consumption then&lt;br /&gt;
   -- always happens, even if the consumption is 0&lt;br /&gt;
   log(&amp;quot;Outlet 1 is on&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 if not devices.system.output1_consumption then&lt;br /&gt;
   -- never happens, even if the consumption is 0&lt;br /&gt;
   log(&amp;quot;Outlet 1 is off&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
== Loops ==&lt;br /&gt;
Lua has &amp;lt;code&amp;gt;break&amp;lt;/code&amp;gt; statement, but no &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt; (use condition inside loop instead).&lt;br /&gt;
=== While ===&lt;br /&gt;
While syntax is not different to other languages:&lt;br /&gt;
 local i = 0&lt;br /&gt;
 while i~=3 do&lt;br /&gt;
   i = i + 1&lt;br /&gt;
   logf(&amp;quot;%d&amp;quot;,i)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
=== Repeat until ===&lt;br /&gt;
Repeat until syntax is the same as Pascal's, other languages have similar do-while loops:&lt;br /&gt;
 local i = 0&lt;br /&gt;
 repeat&lt;br /&gt;
   i = i + 1&lt;br /&gt;
   logf(&amp;quot;%d&amp;quot;,i)&lt;br /&gt;
 until i==3&lt;br /&gt;
&lt;br /&gt;
=== Numeric for ===&lt;br /&gt;
Arrays in Lua are one-based (in indices are not specified, the first one is 1, not 0).&lt;br /&gt;
 local arr = {2,3,7,5}&lt;br /&gt;
 for i=1,#arr do logf(&amp;quot;%d&amp;quot;,arr[i]) end&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;b&amp;gt;for&amp;lt;/b&amp;gt; initVar,limit,increment &amp;lt;b&amp;gt;do&amp;lt;/b&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;i&amp;gt;number assignment&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;initVar&amp;lt;/code&amp;gt; inits loop-local variable&lt;br /&gt;
* &amp;lt;i&amp;gt;number&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;limit&amp;lt;/code&amp;gt; loops until initVar reaches this value&lt;br /&gt;
* &amp;lt;i&amp;gt;optional number&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;increment&amp;lt;/code&amp;gt; after each loop initVar increment by this value (default 1)&lt;br /&gt;
&lt;br /&gt;
=== Generic for ===&lt;br /&gt;
Is rather sophisticated. Most common example (the order of elements in &amp;lt;code&amp;gt;pairs()&amp;lt;/code&amp;gt; is not guaranteed):&lt;br /&gt;
 local tab = {one=1, two=2, three=3}&lt;br /&gt;
 for key,val in pairs(tab) do logf(&amp;quot;%s:%d&amp;quot;,key,val) end&lt;br /&gt;
Generic for syntax&lt;br /&gt;
 &amp;lt;b&amp;gt;for&amp;lt;/b&amp;gt; var_1, ..., var_n &amp;lt;b&amp;gt;in&amp;lt;/b&amp;gt; explist &amp;lt;b&amp;gt;do&amp;lt;/b&amp;gt; block end&lt;br /&gt;
is equivalent to (Full explanation [https://www.lua.org/pil/7.2.html here].)&lt;br /&gt;
 do&lt;br /&gt;
   local _f, _s, _var = explist&lt;br /&gt;
   while true do&lt;br /&gt;
     local var_1, ... , var_n = _f(_s, _var)&lt;br /&gt;
     _var = var_1&lt;br /&gt;
     if _var == nil then break end&lt;br /&gt;
     block&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Iterator closure that holds its state&lt;br /&gt;
 function iter(a)&lt;br /&gt;
   local i = 0&lt;br /&gt;
   return function()&lt;br /&gt;
     i = i+1&lt;br /&gt;
     return a[i]&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 local arr = {2,3,7,5}&lt;br /&gt;
 for value in iter(arr) do&lt;br /&gt;
   logf(&amp;quot;%d&amp;quot;,value)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Stateless iterator (in this case returns variable list: key and value)&lt;br /&gt;
 function iter(a,i)&lt;br /&gt;
   i = i+1&lt;br /&gt;
   if a[i] then return i,a[i] end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 local arr = {2,3,7,5}&lt;br /&gt;
 for k,v in iter,arr,0 do&lt;br /&gt;
   logf(&amp;quot;%d:%d&amp;quot;,k,v)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Same effect using &amp;lt;code&amp;gt;ipairs()&amp;lt;/code&amp;gt; Lua function (without initial state)&lt;br /&gt;
 for k,v in ipairs(arr) do&lt;br /&gt;
   logf(&amp;quot;%d:%d&amp;quot;,k,v)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Now return to the most common example above using &amp;lt;code&amp;gt;pairs()&amp;lt;/code&amp;gt; Lua function and read about &amp;lt;code&amp;gt;pairs()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;ipairs()&amp;lt;/code&amp;gt; implementation [https://www.lua.org/pil/7.3.html here].&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
&lt;br /&gt;
Lua allows multiple results (comma separated):&lt;br /&gt;
&lt;br /&gt;
 function diskSpace()&lt;br /&gt;
   return devices.system.freeSpace, devices.system.totalSpace&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 logf(&amp;quot;Free space: %d MB&amp;quot;, diskSpace())&lt;br /&gt;
 local free,total = diskSpace()&lt;br /&gt;
 logf(&amp;quot;Free space: %d %%&amp;quot;, 100*free/total)&lt;br /&gt;
&lt;br /&gt;
Variable-length arguments are also available:&lt;br /&gt;
&lt;br /&gt;
 function sum(...)&lt;br /&gt;
   local result = 0&lt;br /&gt;
   for _,v in ipairs(arg) do&lt;br /&gt;
     result = result + v&lt;br /&gt;
   end&lt;br /&gt;
   return result&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 logf(&amp;quot;Sum: %d&amp;quot;, sum(2,3,5))&lt;/div&gt;</summary>
		<author><name>Jturon</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=NETIO_Lua_Manual&amp;diff=319</id>
		<title>NETIO Lua Manual</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=NETIO_Lua_Manual&amp;diff=319"/>
		<updated>2017-04-25T11:24:39Z</updated>

		<summary type="html">&lt;p&gt;Jturon: /* Numeric for */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Debugging ==&lt;br /&gt;
To debug your code, use [[Function log()|log()]] and [[Function logf()|logf()]] functions. See the output in system events log.&lt;br /&gt;
&lt;br /&gt;
== Operators ==&lt;br /&gt;
Lua has its own manners:&lt;br /&gt;
* &amp;lt;code&amp;gt;~=&amp;lt;/code&amp;gt; is inequality operator&lt;br /&gt;
* &amp;lt;code&amp;gt;..&amp;lt;/code&amp;gt; is string concatenation (don't use plus)&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;s&amp;gt;i++&amp;lt;/s&amp;gt;&amp;lt;/code&amp;gt; no increment/decrement operator &amp;lt;code&amp;gt;i = i + 1&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;s&amp;gt;max = a&amp;lt;b ? b : a&amp;lt;/s&amp;gt;&amp;lt;/code&amp;gt; no ternary operator. Use (and get used to) and idiom instead: &amp;lt;code&amp;gt;max = (a&amp;lt;b) and b or a&amp;lt;/code&amp;gt;&lt;br /&gt;
* or idiom works: &amp;lt;code&amp;gt;x = x or 42&amp;lt;/code&amp;gt; is equivalent to &amp;lt;code&amp;gt;if not x then x = 42 end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Conditions ==&lt;br /&gt;
Lua conditions has casual syntax, see [https://www.lua.org/pil/4.3.1.html here]. Just keep in mind to merge &amp;lt;code&amp;gt;else&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;elseif&amp;lt;/code&amp;gt; or multiple &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt;s are required.&lt;br /&gt;
&lt;br /&gt;
Note that falsy values are &amp;lt;i&amp;gt;nil&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;false&amp;lt;/i&amp;gt; only. Empty string and 0 evaluates as true. If you come from C, you might be surprised by following snippet:&lt;br /&gt;
&lt;br /&gt;
 if devices.system.output1_consumption then&lt;br /&gt;
   -- always happens, even if the consumption is 0&lt;br /&gt;
   log(&amp;quot;Outlet 1 is on&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 if not devices.system.output1_consumption then&lt;br /&gt;
   -- never happens, even if the consumption is 0&lt;br /&gt;
   log(&amp;quot;Outlet 1 is off&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
== Loops ==&lt;br /&gt;
Lua has &amp;lt;code&amp;gt;break&amp;lt;/code&amp;gt; statement, but no &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt; (use condition inside loop instead).&lt;br /&gt;
=== While ===&lt;br /&gt;
While syntax is not different to other languages:&lt;br /&gt;
 local i = 0&lt;br /&gt;
 while i~=3 do&lt;br /&gt;
   i = i + 1&lt;br /&gt;
   logf(&amp;quot;%d&amp;quot;,i)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
=== Repeat until ===&lt;br /&gt;
Repeat until syntax is the same as Pascal's, other languages have similar do-while loops:&lt;br /&gt;
 local i = 0&lt;br /&gt;
 repeat&lt;br /&gt;
   i = i + 1&lt;br /&gt;
   logf(&amp;quot;%d&amp;quot;,i)&lt;br /&gt;
 until i==3&lt;br /&gt;
&lt;br /&gt;
=== Numeric for ===&lt;br /&gt;
Arrays in Lua are 1 based (in indices are not specified, the first one is 1, not 0)&lt;br /&gt;
 local arr = {2,3,7,5}&lt;br /&gt;
 for i=1,#arr do logf(&amp;quot;%d&amp;quot;,arr[i]) end&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;b&amp;gt;for&amp;lt;/b&amp;gt; initVar,limit,increment &amp;lt;b&amp;gt;do&amp;lt;/b&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;i&amp;gt;number assignment&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;initVar&amp;lt;/code&amp;gt; inits loop-local variable&lt;br /&gt;
* &amp;lt;i&amp;gt;number&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;limit&amp;lt;/code&amp;gt; loops until initVar reaches this value&lt;br /&gt;
* &amp;lt;i&amp;gt;optional number&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;increment&amp;lt;/code&amp;gt; after each loop initVar increment by this value (default 1)&lt;br /&gt;
&lt;br /&gt;
=== Generic for ===&lt;br /&gt;
Is rather sophisticated. Most common example (the order of elements in &amp;lt;code&amp;gt;pairs()&amp;lt;/code&amp;gt; is not guaranteed):&lt;br /&gt;
 local tab = {one=1, two=2, three=3}&lt;br /&gt;
 for key,val in pairs(tab) do logf(&amp;quot;%s:%d&amp;quot;,key,val) end&lt;br /&gt;
Generic for syntax&lt;br /&gt;
 &amp;lt;b&amp;gt;for&amp;lt;/b&amp;gt; var_1, ..., var_n &amp;lt;b&amp;gt;in&amp;lt;/b&amp;gt; explist &amp;lt;b&amp;gt;do&amp;lt;/b&amp;gt; block end&lt;br /&gt;
is equivalent to (Full explanation [https://www.lua.org/pil/7.2.html here].)&lt;br /&gt;
 do&lt;br /&gt;
   local _f, _s, _var = explist&lt;br /&gt;
   while true do&lt;br /&gt;
     local var_1, ... , var_n = _f(_s, _var)&lt;br /&gt;
     _var = var_1&lt;br /&gt;
     if _var == nil then break end&lt;br /&gt;
     block&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Iterator closure that holds its state&lt;br /&gt;
 function iter(a)&lt;br /&gt;
   local i = 0&lt;br /&gt;
   return function()&lt;br /&gt;
     i = i+1&lt;br /&gt;
     return a[i]&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 local arr = {2,3,7,5}&lt;br /&gt;
 for value in iter(arr) do&lt;br /&gt;
   logf(&amp;quot;%d&amp;quot;,value)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Stateless iterator (in this case returns variable list: key and value)&lt;br /&gt;
 function iter(a,i)&lt;br /&gt;
   i = i+1&lt;br /&gt;
   if a[i] then return i,a[i] end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 local arr = {2,3,7,5}&lt;br /&gt;
 for k,v in iter,arr,0 do&lt;br /&gt;
   logf(&amp;quot;%d:%d&amp;quot;,k,v)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Same effect using &amp;lt;code&amp;gt;ipairs()&amp;lt;/code&amp;gt; Lua function (without initial state)&lt;br /&gt;
 for k,v in ipairs(arr) do&lt;br /&gt;
   logf(&amp;quot;%d:%d&amp;quot;,k,v)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Now return to the most common example above using &amp;lt;code&amp;gt;pairs()&amp;lt;/code&amp;gt; Lua function and read about &amp;lt;code&amp;gt;pairs()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;ipairs()&amp;lt;/code&amp;gt; implementation [https://www.lua.org/pil/7.3.html here].&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
&lt;br /&gt;
Lua allows multiple results (comma separated):&lt;br /&gt;
&lt;br /&gt;
 function diskSpace()&lt;br /&gt;
   return devices.system.freeSpace, devices.system.totalSpace&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 logf(&amp;quot;Free space: %d MB&amp;quot;, diskSpace())&lt;br /&gt;
 local free,total = diskSpace()&lt;br /&gt;
 logf(&amp;quot;Free space: %d %%&amp;quot;, 100*free/total)&lt;br /&gt;
&lt;br /&gt;
Variable-length arguments are also available:&lt;br /&gt;
&lt;br /&gt;
 function sum(...)&lt;br /&gt;
   local result = 0&lt;br /&gt;
   for _,v in ipairs(arg) do&lt;br /&gt;
     result = result + v&lt;br /&gt;
   end&lt;br /&gt;
   return result&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 logf(&amp;quot;Sum: %d&amp;quot;, sum(2,3,5))&lt;/div&gt;</summary>
		<author><name>Jturon</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=NETIO_Lua_Manual&amp;diff=318</id>
		<title>NETIO Lua Manual</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=NETIO_Lua_Manual&amp;diff=318"/>
		<updated>2017-04-25T11:11:26Z</updated>

		<summary type="html">&lt;p&gt;Jturon: /* Conditions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Debugging ==&lt;br /&gt;
To debug your code, use [[Function log()|log()]] and [[Function logf()|logf()]] functions. See the output in system events log.&lt;br /&gt;
&lt;br /&gt;
== Operators ==&lt;br /&gt;
Lua has its own manners:&lt;br /&gt;
* &amp;lt;code&amp;gt;~=&amp;lt;/code&amp;gt; is inequality operator&lt;br /&gt;
* &amp;lt;code&amp;gt;..&amp;lt;/code&amp;gt; is string concatenation (don't use plus)&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;s&amp;gt;i++&amp;lt;/s&amp;gt;&amp;lt;/code&amp;gt; no increment/decrement operator &amp;lt;code&amp;gt;i = i + 1&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;s&amp;gt;max = a&amp;lt;b ? b : a&amp;lt;/s&amp;gt;&amp;lt;/code&amp;gt; no ternary operator. Use (and get used to) and idiom instead: &amp;lt;code&amp;gt;max = (a&amp;lt;b) and b or a&amp;lt;/code&amp;gt;&lt;br /&gt;
* or idiom works: &amp;lt;code&amp;gt;x = x or 42&amp;lt;/code&amp;gt; is equivalent to &amp;lt;code&amp;gt;if not x then x = 42 end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Conditions ==&lt;br /&gt;
Lua conditions has casual syntax, see [https://www.lua.org/pil/4.3.1.html here]. Just keep in mind to merge &amp;lt;code&amp;gt;else&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;elseif&amp;lt;/code&amp;gt; or multiple &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt;s are required.&lt;br /&gt;
&lt;br /&gt;
Note that falsy values are &amp;lt;i&amp;gt;nil&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;false&amp;lt;/i&amp;gt; only. Empty string and 0 evaluates as true. If you come from C, you might be surprised by following snippet:&lt;br /&gt;
&lt;br /&gt;
 if devices.system.output1_consumption then&lt;br /&gt;
   -- always happens, even if the consumption is 0&lt;br /&gt;
   log(&amp;quot;Outlet 1 is on&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 if not devices.system.output1_consumption then&lt;br /&gt;
   -- never happens, even if the consumption is 0&lt;br /&gt;
   log(&amp;quot;Outlet 1 is off&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
== Loops ==&lt;br /&gt;
Lua has &amp;lt;code&amp;gt;break&amp;lt;/code&amp;gt; statement, but no &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt; (use condition inside loop instead).&lt;br /&gt;
=== While ===&lt;br /&gt;
While syntax is not different to other languages:&lt;br /&gt;
 local i = 0&lt;br /&gt;
 while i~=3 do&lt;br /&gt;
   i = i + 1&lt;br /&gt;
   logf(&amp;quot;%d&amp;quot;,i)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
=== Repeat until ===&lt;br /&gt;
Repeat until syntax is the same as Pascal's, other languages have similar do-while loops:&lt;br /&gt;
 local i = 0&lt;br /&gt;
 repeat&lt;br /&gt;
   i = i + 1&lt;br /&gt;
   logf(&amp;quot;%d&amp;quot;,i)&lt;br /&gt;
 until i==3&lt;br /&gt;
&lt;br /&gt;
=== Numeric for ===&lt;br /&gt;
 local arr = {2,3,7,5}&lt;br /&gt;
 for i=1,#arr do logf(&amp;quot;%d&amp;quot;,arr[i]) end&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;b&amp;gt;for&amp;lt;/b&amp;gt; initVar,limit,increment &amp;lt;b&amp;gt;do&amp;lt;/b&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;i&amp;gt;number assignment&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;initVar&amp;lt;/code&amp;gt; inits loop-local variable&lt;br /&gt;
* &amp;lt;i&amp;gt;number&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;limit&amp;lt;/code&amp;gt; loops until initVar reaches this value&lt;br /&gt;
* &amp;lt;i&amp;gt;optional number&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;increment&amp;lt;/code&amp;gt; after each loop initVar increment by this value (default 1)&lt;br /&gt;
&lt;br /&gt;
=== Generic for ===&lt;br /&gt;
Is rather sophisticated. Most common example (the order of elements in &amp;lt;code&amp;gt;pairs()&amp;lt;/code&amp;gt; is not guaranteed):&lt;br /&gt;
 local tab = {one=1, two=2, three=3}&lt;br /&gt;
 for key,val in pairs(tab) do logf(&amp;quot;%s:%d&amp;quot;,key,val) end&lt;br /&gt;
Generic for syntax&lt;br /&gt;
 &amp;lt;b&amp;gt;for&amp;lt;/b&amp;gt; var_1, ..., var_n &amp;lt;b&amp;gt;in&amp;lt;/b&amp;gt; explist &amp;lt;b&amp;gt;do&amp;lt;/b&amp;gt; block end&lt;br /&gt;
is equivalent to (Full explanation [https://www.lua.org/pil/7.2.html here].)&lt;br /&gt;
 do&lt;br /&gt;
   local _f, _s, _var = explist&lt;br /&gt;
   while true do&lt;br /&gt;
     local var_1, ... , var_n = _f(_s, _var)&lt;br /&gt;
     _var = var_1&lt;br /&gt;
     if _var == nil then break end&lt;br /&gt;
     block&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Iterator closure that holds its state&lt;br /&gt;
 function iter(a)&lt;br /&gt;
   local i = 0&lt;br /&gt;
   return function()&lt;br /&gt;
     i = i+1&lt;br /&gt;
     return a[i]&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 local arr = {2,3,7,5}&lt;br /&gt;
 for value in iter(arr) do&lt;br /&gt;
   logf(&amp;quot;%d&amp;quot;,value)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Stateless iterator (in this case returns variable list: key and value)&lt;br /&gt;
 function iter(a,i)&lt;br /&gt;
   i = i+1&lt;br /&gt;
   if a[i] then return i,a[i] end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 local arr = {2,3,7,5}&lt;br /&gt;
 for k,v in iter,arr,0 do&lt;br /&gt;
   logf(&amp;quot;%d:%d&amp;quot;,k,v)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Same effect using &amp;lt;code&amp;gt;ipairs()&amp;lt;/code&amp;gt; Lua function (without initial state)&lt;br /&gt;
 for k,v in ipairs(arr) do&lt;br /&gt;
   logf(&amp;quot;%d:%d&amp;quot;,k,v)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Now return to the most common example above using &amp;lt;code&amp;gt;pairs()&amp;lt;/code&amp;gt; Lua function and read about &amp;lt;code&amp;gt;pairs()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;ipairs()&amp;lt;/code&amp;gt; implementation [https://www.lua.org/pil/7.3.html here].&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
&lt;br /&gt;
Lua allows multiple results (comma separated):&lt;br /&gt;
&lt;br /&gt;
 function diskSpace()&lt;br /&gt;
   return devices.system.freeSpace, devices.system.totalSpace&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 logf(&amp;quot;Free space: %d MB&amp;quot;, diskSpace())&lt;br /&gt;
 local free,total = diskSpace()&lt;br /&gt;
 logf(&amp;quot;Free space: %d %%&amp;quot;, 100*free/total)&lt;br /&gt;
&lt;br /&gt;
Variable-length arguments are also available:&lt;br /&gt;
&lt;br /&gt;
 function sum(...)&lt;br /&gt;
   local result = 0&lt;br /&gt;
   for _,v in ipairs(arg) do&lt;br /&gt;
     result = result + v&lt;br /&gt;
   end&lt;br /&gt;
   return result&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 logf(&amp;quot;Sum: %d&amp;quot;, sum(2,3,5))&lt;/div&gt;</summary>
		<author><name>Jturon</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=Function_mail()&amp;diff=317</id>
		<title>Function mail()</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=Function_mail()&amp;diff=317"/>
		<updated>2017-04-25T11:09:30Z</updated>

		<summary type="html">&lt;p&gt;Jturon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:function mail()}}&lt;br /&gt;
Send SMTP mail. Don't forget to set SMTP server in Settings &amp;amp;rarr; E-mail in Netio web interface.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;i&amp;gt;nil&amp;lt;/i&amp;gt; &amp;lt;b&amp;gt;mail&amp;lt;/b&amp;gt;(&amp;lt;i&amp;gt;string&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;recipient&amp;lt;/code&amp;gt;, &amp;lt;i&amp;gt;string&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;subject&amp;lt;/code&amp;gt;, &amp;lt;i&amp;gt;string&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;body&amp;lt;/code&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
* &amp;lt;i&amp;gt;string&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;recipient&amp;lt;/code&amp;gt; - e-mail address of the recipient (To)&lt;br /&gt;
* &amp;lt;i&amp;gt;string&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;subject&amp;lt;/code&amp;gt; subject of the e-mail&lt;br /&gt;
* &amp;lt;i&amp;gt;string&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;body&amp;lt;/code&amp;gt; body of the e-mail&lt;br /&gt;
&lt;br /&gt;
=== Return value ===&lt;br /&gt;
 nil&lt;br /&gt;
&lt;br /&gt;
=== Usage ===&lt;br /&gt;
 -- sends HTTP GET request&lt;br /&gt;
 mail(&amp;quot;johndoe@example.com&amp;quot;,&amp;quot;Socket S0732 warning&amp;quot;,&amp;quot;Warning: S0732 consumption exceeded 10kWh.&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;/div&gt;</summary>
		<author><name>Jturon</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=NETIO_Lua_Manual&amp;diff=316</id>
		<title>NETIO Lua Manual</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=NETIO_Lua_Manual&amp;diff=316"/>
		<updated>2017-04-25T11:06:48Z</updated>

		<summary type="html">&lt;p&gt;Jturon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Debugging ==&lt;br /&gt;
To debug your code, use [[Function log()|log()]] and [[Function logf()|logf()]] functions. See the output in system events log.&lt;br /&gt;
&lt;br /&gt;
== Operators ==&lt;br /&gt;
Lua has its own manners:&lt;br /&gt;
* &amp;lt;code&amp;gt;~=&amp;lt;/code&amp;gt; is inequality operator&lt;br /&gt;
* &amp;lt;code&amp;gt;..&amp;lt;/code&amp;gt; is string concatenation (don't use plus)&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;s&amp;gt;i++&amp;lt;/s&amp;gt;&amp;lt;/code&amp;gt; no increment/decrement operator &amp;lt;code&amp;gt;i = i + 1&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;&amp;lt;s&amp;gt;max = a&amp;lt;b ? b : a&amp;lt;/s&amp;gt;&amp;lt;/code&amp;gt; no ternary operator. Use (and get used to) and idiom instead: &amp;lt;code&amp;gt;max = (a&amp;lt;b) and b or a&amp;lt;/code&amp;gt;&lt;br /&gt;
* or idiom works: &amp;lt;code&amp;gt;x = x or 42&amp;lt;/code&amp;gt; is equivalent to &amp;lt;code&amp;gt;if not x then x = 42 end&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Conditions ==&lt;br /&gt;
Lua conditions has usual syntax, see [https://www.lua.org/pil/4.3.1.html here]. Just keep in mind to merge &amp;lt;code&amp;gt;else&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;elseif&amp;lt;/code&amp;gt; or multiple &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt;s are required.&lt;br /&gt;
&lt;br /&gt;
Note that falsy values are &amp;lt;i&amp;gt;nil&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;false&amp;lt;/i&amp;gt; only. Empty string and 0 evaluates as true. If you come from C, you might be surprised by following snippet:&lt;br /&gt;
&lt;br /&gt;
 if devices.system.output1_consumption then&lt;br /&gt;
   -- always happens, even if the consumption is 0&lt;br /&gt;
   log(&amp;quot;Outlet 1 is on&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 if not devices.system.output1_consumption then&lt;br /&gt;
   -- never happens, even if the consumption is 0&lt;br /&gt;
   log(&amp;quot;Outlet 1 is off&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
== Loops ==&lt;br /&gt;
Lua has &amp;lt;code&amp;gt;break&amp;lt;/code&amp;gt; statement, but no &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt; (use condition inside loop instead).&lt;br /&gt;
=== While ===&lt;br /&gt;
While syntax is not different to other languages:&lt;br /&gt;
 local i = 0&lt;br /&gt;
 while i~=3 do&lt;br /&gt;
   i = i + 1&lt;br /&gt;
   logf(&amp;quot;%d&amp;quot;,i)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
=== Repeat until ===&lt;br /&gt;
Repeat until syntax is the same as Pascal's, other languages have similar do-while loops:&lt;br /&gt;
 local i = 0&lt;br /&gt;
 repeat&lt;br /&gt;
   i = i + 1&lt;br /&gt;
   logf(&amp;quot;%d&amp;quot;,i)&lt;br /&gt;
 until i==3&lt;br /&gt;
&lt;br /&gt;
=== Numeric for ===&lt;br /&gt;
 local arr = {2,3,7,5}&lt;br /&gt;
 for i=1,#arr do logf(&amp;quot;%d&amp;quot;,arr[i]) end&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;b&amp;gt;for&amp;lt;/b&amp;gt; initVar,limit,increment &amp;lt;b&amp;gt;do&amp;lt;/b&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;i&amp;gt;number assignment&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;initVar&amp;lt;/code&amp;gt; inits loop-local variable&lt;br /&gt;
* &amp;lt;i&amp;gt;number&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;limit&amp;lt;/code&amp;gt; loops until initVar reaches this value&lt;br /&gt;
* &amp;lt;i&amp;gt;optional number&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;increment&amp;lt;/code&amp;gt; after each loop initVar increment by this value (default 1)&lt;br /&gt;
&lt;br /&gt;
=== Generic for ===&lt;br /&gt;
Is rather sophisticated. Most common example (the order of elements in &amp;lt;code&amp;gt;pairs()&amp;lt;/code&amp;gt; is not guaranteed):&lt;br /&gt;
 local tab = {one=1, two=2, three=3}&lt;br /&gt;
 for key,val in pairs(tab) do logf(&amp;quot;%s:%d&amp;quot;,key,val) end&lt;br /&gt;
Generic for syntax&lt;br /&gt;
 &amp;lt;b&amp;gt;for&amp;lt;/b&amp;gt; var_1, ..., var_n &amp;lt;b&amp;gt;in&amp;lt;/b&amp;gt; explist &amp;lt;b&amp;gt;do&amp;lt;/b&amp;gt; block end&lt;br /&gt;
is equivalent to (Full explanation [https://www.lua.org/pil/7.2.html here].)&lt;br /&gt;
 do&lt;br /&gt;
   local _f, _s, _var = explist&lt;br /&gt;
   while true do&lt;br /&gt;
     local var_1, ... , var_n = _f(_s, _var)&lt;br /&gt;
     _var = var_1&lt;br /&gt;
     if _var == nil then break end&lt;br /&gt;
     block&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Iterator closure that holds its state&lt;br /&gt;
 function iter(a)&lt;br /&gt;
   local i = 0&lt;br /&gt;
   return function()&lt;br /&gt;
     i = i+1&lt;br /&gt;
     return a[i]&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 local arr = {2,3,7,5}&lt;br /&gt;
 for value in iter(arr) do&lt;br /&gt;
   logf(&amp;quot;%d&amp;quot;,value)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Stateless iterator (in this case returns variable list: key and value)&lt;br /&gt;
 function iter(a,i)&lt;br /&gt;
   i = i+1&lt;br /&gt;
   if a[i] then return i,a[i] end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 local arr = {2,3,7,5}&lt;br /&gt;
 for k,v in iter,arr,0 do&lt;br /&gt;
   logf(&amp;quot;%d:%d&amp;quot;,k,v)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Same effect using &amp;lt;code&amp;gt;ipairs()&amp;lt;/code&amp;gt; Lua function (without initial state)&lt;br /&gt;
 for k,v in ipairs(arr) do&lt;br /&gt;
   logf(&amp;quot;%d:%d&amp;quot;,k,v)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Now return to the most common example above using &amp;lt;code&amp;gt;pairs()&amp;lt;/code&amp;gt; Lua function and read about &amp;lt;code&amp;gt;pairs()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;ipairs()&amp;lt;/code&amp;gt; implementation [https://www.lua.org/pil/7.3.html here].&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
&lt;br /&gt;
Lua allows multiple results (comma separated):&lt;br /&gt;
&lt;br /&gt;
 function diskSpace()&lt;br /&gt;
   return devices.system.freeSpace, devices.system.totalSpace&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 logf(&amp;quot;Free space: %d MB&amp;quot;, diskSpace())&lt;br /&gt;
 local free,total = diskSpace()&lt;br /&gt;
 logf(&amp;quot;Free space: %d %%&amp;quot;, 100*free/total)&lt;br /&gt;
&lt;br /&gt;
Variable-length arguments are also available:&lt;br /&gt;
&lt;br /&gt;
 function sum(...)&lt;br /&gt;
   local result = 0&lt;br /&gt;
   for _,v in ipairs(arg) do&lt;br /&gt;
     result = result + v&lt;br /&gt;
   end&lt;br /&gt;
   return result&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 logf(&amp;quot;Sum: %d&amp;quot;, sum(2,3,5))&lt;/div&gt;</summary>
		<author><name>Jturon</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=NETIO_Lua_Manual&amp;diff=315</id>
		<title>NETIO Lua Manual</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=NETIO_Lua_Manual&amp;diff=315"/>
		<updated>2017-04-25T10:57:59Z</updated>

		<summary type="html">&lt;p&gt;Jturon: /* Conditions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Debugging ==&lt;br /&gt;
To debug your code, use [[Function log()|log()]] and [[Function logf()|logf()]] functions. See the output in system events log.&lt;br /&gt;
&lt;br /&gt;
== Conditions ==&lt;br /&gt;
Lua conditions has usual syntax, see [https://www.lua.org/pil/4.3.1.html here]. Just keep in mind to merge &amp;lt;code&amp;gt;else&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;elseif&amp;lt;/code&amp;gt; or multiple &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt;s are required.&lt;br /&gt;
&lt;br /&gt;
Note that falsy values are &amp;lt;i&amp;gt;nil&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;false&amp;lt;/i&amp;gt; only. Empty string and 0 evaluates as true. If you come from C, you might be surprised by following snippet:&lt;br /&gt;
&lt;br /&gt;
 if devices.system.output1_consumption then&lt;br /&gt;
   -- always happens, even if the consumption is 0&lt;br /&gt;
   log(&amp;quot;Outlet 1 is on&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
 if not devices.system.output1_consumption then&lt;br /&gt;
   -- never happens, even if the consumption is 0&lt;br /&gt;
   log(&amp;quot;Outlet 1 is off&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
== Loops ==&lt;br /&gt;
Lua has &amp;lt;code&amp;gt;break&amp;lt;/code&amp;gt; statement, but no &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt; (use condition inside loop instead).&lt;br /&gt;
=== While ===&lt;br /&gt;
While syntax is not different to other languages:&lt;br /&gt;
 local i = 0&lt;br /&gt;
 while i~=3 do&lt;br /&gt;
   i = i + 1&lt;br /&gt;
   logf(&amp;quot;%d&amp;quot;,i)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
=== Repeat until ===&lt;br /&gt;
Repeat until syntax is the same as Pascal's, other languages have similar do-while loops:&lt;br /&gt;
 local i = 0&lt;br /&gt;
 repeat&lt;br /&gt;
   i = i + 1&lt;br /&gt;
   logf(&amp;quot;%d&amp;quot;,i)&lt;br /&gt;
 until i==3&lt;br /&gt;
&lt;br /&gt;
=== Numeric for ===&lt;br /&gt;
 local arr = {2,3,7,5}&lt;br /&gt;
 for i=1,#arr do logf(&amp;quot;%d&amp;quot;,arr[i]) end&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;b&amp;gt;for&amp;lt;/b&amp;gt; initVar,limit,increment &amp;lt;b&amp;gt;do&amp;lt;/b&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;i&amp;gt;number assignment&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;initVar&amp;lt;/code&amp;gt; inits loop-local variable&lt;br /&gt;
* &amp;lt;i&amp;gt;number&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;limit&amp;lt;/code&amp;gt; loops until initVar reaches this value&lt;br /&gt;
* &amp;lt;i&amp;gt;optional number&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;increment&amp;lt;/code&amp;gt; after each loop initVar increment by this value (default 1)&lt;br /&gt;
&lt;br /&gt;
=== Generic for ===&lt;br /&gt;
Is rather sophisticated. Most common example (the order of elements in &amp;lt;code&amp;gt;pairs()&amp;lt;/code&amp;gt; is not guaranteed):&lt;br /&gt;
 local tab = {one=1, two=2, three=3}&lt;br /&gt;
 for key,val in pairs(tab) do logf(&amp;quot;%s:%d&amp;quot;,key,val) end&lt;br /&gt;
Generic for syntax&lt;br /&gt;
 &amp;lt;b&amp;gt;for&amp;lt;/b&amp;gt; var_1, ..., var_n &amp;lt;b&amp;gt;in&amp;lt;/b&amp;gt; explist &amp;lt;b&amp;gt;do&amp;lt;/b&amp;gt; block end&lt;br /&gt;
is equivalent to (Full explanation [https://www.lua.org/pil/7.2.html here].)&lt;br /&gt;
 do&lt;br /&gt;
   local _f, _s, _var = explist&lt;br /&gt;
   while true do&lt;br /&gt;
     local var_1, ... , var_n = _f(_s, _var)&lt;br /&gt;
     _var = var_1&lt;br /&gt;
     if _var == nil then break end&lt;br /&gt;
     block&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Iterator closure that holds its state&lt;br /&gt;
 function iter(a)&lt;br /&gt;
   local i = 0&lt;br /&gt;
   return function()&lt;br /&gt;
     i = i+1&lt;br /&gt;
     return a[i]&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 local arr = {2,3,7,5}&lt;br /&gt;
 for value in iter(arr) do&lt;br /&gt;
   logf(&amp;quot;%d&amp;quot;,value)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Stateless iterator (in this case returns variable list: key and value)&lt;br /&gt;
 function iter(a,i)&lt;br /&gt;
   i = i+1&lt;br /&gt;
   if a[i] then return i,a[i] end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 local arr = {2,3,7,5}&lt;br /&gt;
 for k,v in iter,arr,0 do&lt;br /&gt;
   logf(&amp;quot;%d:%d&amp;quot;,k,v)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Same effect using &amp;lt;code&amp;gt;ipairs()&amp;lt;/code&amp;gt; Lua function (without initial state)&lt;br /&gt;
 for k,v in ipairs(arr) do&lt;br /&gt;
   logf(&amp;quot;%d:%d&amp;quot;,k,v)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Now return to the most common example above using &amp;lt;code&amp;gt;pairs()&amp;lt;/code&amp;gt; Lua function and read about &amp;lt;code&amp;gt;pairs()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;ipairs()&amp;lt;/code&amp;gt; implementation [https://www.lua.org/pil/7.3.html here].&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
&lt;br /&gt;
Lua allows multiple results (comma separated):&lt;br /&gt;
&lt;br /&gt;
 function diskSpace()&lt;br /&gt;
   return devices.system.freeSpace, devices.system.totalSpace&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 logf(&amp;quot;Free space: %d MB&amp;quot;, diskSpace())&lt;br /&gt;
 local free,total = diskSpace()&lt;br /&gt;
 logf(&amp;quot;Free space: %d %%&amp;quot;, 100*free/total)&lt;br /&gt;
&lt;br /&gt;
Variable-length arguments are also available:&lt;br /&gt;
&lt;br /&gt;
 function sum(...)&lt;br /&gt;
   local result = 0&lt;br /&gt;
   for _,v in ipairs(arg) do&lt;br /&gt;
     result = result + v&lt;br /&gt;
   end&lt;br /&gt;
   return result&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 logf(&amp;quot;Sum: %d&amp;quot;, sum(2,3,5))&lt;/div&gt;</summary>
		<author><name>Jturon</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=NETIO_Lua_Manual&amp;diff=314</id>
		<title>NETIO Lua Manual</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=NETIO_Lua_Manual&amp;diff=314"/>
		<updated>2017-04-25T10:38:49Z</updated>

		<summary type="html">&lt;p&gt;Jturon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Debugging ==&lt;br /&gt;
To debug your code, use [[Function log()|log()]] and [[Function logf()|logf()]] functions. See the output in system events log.&lt;br /&gt;
&lt;br /&gt;
== Conditions ==&lt;br /&gt;
Lua conditions has usual syntax, see [https://www.lua.org/pil/4.3.1.html here]. Just keep in mind to merge &amp;lt;code&amp;gt;else&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;elseif&amp;lt;/code&amp;gt; or multiple &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt;s are required.&lt;br /&gt;
&lt;br /&gt;
== Loops ==&lt;br /&gt;
Lua has &amp;lt;code&amp;gt;break&amp;lt;/code&amp;gt; statement, but no &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt; (use condition inside loop instead).&lt;br /&gt;
=== While ===&lt;br /&gt;
While syntax is not different to other languages:&lt;br /&gt;
 local i = 0&lt;br /&gt;
 while i~=3 do&lt;br /&gt;
   i = i + 1&lt;br /&gt;
   logf(&amp;quot;%d&amp;quot;,i)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
=== Repeat until ===&lt;br /&gt;
Repeat until syntax is the same as Pascal's, other languages have similar do-while loops:&lt;br /&gt;
 local i = 0&lt;br /&gt;
 repeat&lt;br /&gt;
   i = i + 1&lt;br /&gt;
   logf(&amp;quot;%d&amp;quot;,i)&lt;br /&gt;
 until i==3&lt;br /&gt;
&lt;br /&gt;
=== Numeric for ===&lt;br /&gt;
 local arr = {2,3,7,5}&lt;br /&gt;
 for i=1,#arr do logf(&amp;quot;%d&amp;quot;,arr[i]) end&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;b&amp;gt;for&amp;lt;/b&amp;gt; initVar,limit,increment &amp;lt;b&amp;gt;do&amp;lt;/b&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;i&amp;gt;number assignment&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;initVar&amp;lt;/code&amp;gt; inits loop-local variable&lt;br /&gt;
* &amp;lt;i&amp;gt;number&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;limit&amp;lt;/code&amp;gt; loops until initVar reaches this value&lt;br /&gt;
* &amp;lt;i&amp;gt;optional number&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;increment&amp;lt;/code&amp;gt; after each loop initVar increment by this value (default 1)&lt;br /&gt;
&lt;br /&gt;
=== Generic for ===&lt;br /&gt;
Is rather sophisticated. Most common example (the order of elements in &amp;lt;code&amp;gt;pairs()&amp;lt;/code&amp;gt; is not guaranteed):&lt;br /&gt;
 local tab = {one=1, two=2, three=3}&lt;br /&gt;
 for key,val in pairs(tab) do logf(&amp;quot;%s:%d&amp;quot;,key,val) end&lt;br /&gt;
Generic for syntax&lt;br /&gt;
 &amp;lt;b&amp;gt;for&amp;lt;/b&amp;gt; var_1, ..., var_n &amp;lt;b&amp;gt;in&amp;lt;/b&amp;gt; explist &amp;lt;b&amp;gt;do&amp;lt;/b&amp;gt; block end&lt;br /&gt;
is equivalent to (Full explanation [https://www.lua.org/pil/7.2.html here].)&lt;br /&gt;
 do&lt;br /&gt;
   local _f, _s, _var = explist&lt;br /&gt;
   while true do&lt;br /&gt;
     local var_1, ... , var_n = _f(_s, _var)&lt;br /&gt;
     _var = var_1&lt;br /&gt;
     if _var == nil then break end&lt;br /&gt;
     block&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Iterator closure that holds its state&lt;br /&gt;
 function iter(a)&lt;br /&gt;
   local i = 0&lt;br /&gt;
   return function()&lt;br /&gt;
     i = i+1&lt;br /&gt;
     return a[i]&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 local arr = {2,3,7,5}&lt;br /&gt;
 for value in iter(arr) do&lt;br /&gt;
   logf(&amp;quot;%d&amp;quot;,value)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Stateless iterator (in this case returns variable list: key and value)&lt;br /&gt;
 function iter(a,i)&lt;br /&gt;
   i = i+1&lt;br /&gt;
   if a[i] then return i,a[i] end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 local arr = {2,3,7,5}&lt;br /&gt;
 for k,v in iter,arr,0 do&lt;br /&gt;
   logf(&amp;quot;%d:%d&amp;quot;,k,v)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Same effect using &amp;lt;code&amp;gt;ipairs()&amp;lt;/code&amp;gt; Lua function (without initial state)&lt;br /&gt;
 for k,v in ipairs(arr) do&lt;br /&gt;
   logf(&amp;quot;%d:%d&amp;quot;,k,v)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Now return to the most common example above using &amp;lt;code&amp;gt;pairs()&amp;lt;/code&amp;gt; Lua function and read about &amp;lt;code&amp;gt;pairs()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;ipairs()&amp;lt;/code&amp;gt; implementation [https://www.lua.org/pil/7.3.html here].&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
&lt;br /&gt;
Lua allows multiple results (comma separated):&lt;br /&gt;
&lt;br /&gt;
 function diskSpace()&lt;br /&gt;
   return devices.system.freeSpace, devices.system.totalSpace&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 logf(&amp;quot;Free space: %d MB&amp;quot;, diskSpace())&lt;br /&gt;
 local free,total = diskSpace()&lt;br /&gt;
 logf(&amp;quot;Free space: %d %%&amp;quot;, 100*free/total)&lt;br /&gt;
&lt;br /&gt;
Variable-length arguments are also available:&lt;br /&gt;
&lt;br /&gt;
 function sum(...)&lt;br /&gt;
   local result = 0&lt;br /&gt;
   for _,v in ipairs(arg) do&lt;br /&gt;
     result = result + v&lt;br /&gt;
   end&lt;br /&gt;
   return result&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 logf(&amp;quot;Sum: %d&amp;quot;, sum(2,3,5))&lt;/div&gt;</summary>
		<author><name>Jturon</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=NETIO_Lua_Manual&amp;diff=313</id>
		<title>NETIO Lua Manual</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=NETIO_Lua_Manual&amp;diff=313"/>
		<updated>2017-04-25T09:15:00Z</updated>

		<summary type="html">&lt;p&gt;Jturon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Debugging ==&lt;br /&gt;
To debug your code, use [[Function log()|log()]] and [[Function logf()|logf()]] functions. See the output in system events log.&lt;br /&gt;
&lt;br /&gt;
== Conditions ==&lt;br /&gt;
Lua conditions has usual syntax, see [https://www.lua.org/pil/4.3.1.html here]. Just keep in mind to merge &amp;lt;code&amp;gt;else&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;elseif&amp;lt;/code&amp;gt; or multiple &amp;lt;code&amp;gt;end&amp;lt;/code&amp;gt;s are required.&lt;br /&gt;
&lt;br /&gt;
== Loops ==&lt;br /&gt;
Lua has &amp;lt;code&amp;gt;break&amp;lt;/code&amp;gt; statement, but no &amp;lt;code&amp;gt;continue&amp;lt;/code&amp;gt; (use condition inside loop instead).&lt;br /&gt;
=== While ===&lt;br /&gt;
While syntax is not different to other languages:&lt;br /&gt;
 local i = 0&lt;br /&gt;
 while i~=3 do&lt;br /&gt;
   i = i + 1&lt;br /&gt;
   logf(&amp;quot;%d&amp;quot;,i)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
=== Repeat until ===&lt;br /&gt;
Repeat until syntax is the same as Pascal's, other languages have similar do-while loops:&lt;br /&gt;
 local i = 0&lt;br /&gt;
 repeat&lt;br /&gt;
   i = i + 1&lt;br /&gt;
   logf(&amp;quot;%d&amp;quot;,i)&lt;br /&gt;
 until i==3&lt;br /&gt;
&lt;br /&gt;
=== Numeric for ===&lt;br /&gt;
 local arr = {2,3,7,5}&lt;br /&gt;
 for i=1,#arr do logf(&amp;quot;%d&amp;quot;,arr[i]) end&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;b&amp;gt;for&amp;lt;/b&amp;gt; initVar,limit,increment &amp;lt;b&amp;gt;do&amp;lt;/b&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;i&amp;gt;number assignment&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;initVar&amp;lt;/code&amp;gt; inits loop-local variable&lt;br /&gt;
* &amp;lt;i&amp;gt;number&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;limit&amp;lt;/code&amp;gt; loops until initVar reaches this value&lt;br /&gt;
* &amp;lt;i&amp;gt;optional number&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;increment&amp;lt;/code&amp;gt; after each loop initVar increment by this value (default 1)&lt;br /&gt;
&lt;br /&gt;
=== Generic for ===&lt;br /&gt;
Is rather sophisticated. Most common example (the order of elements in &amp;lt;code&amp;gt;pairs()&amp;lt;/code&amp;gt; is not guaranteed):&lt;br /&gt;
 local tab = {one=1, two=2, three=3}&lt;br /&gt;
 for key,val in pairs(tab) do logf(&amp;quot;%s:%d&amp;quot;,key,val) end&lt;br /&gt;
Generic for syntax&lt;br /&gt;
 &amp;lt;b&amp;gt;for&amp;lt;/b&amp;gt; var_1, ..., var_n &amp;lt;b&amp;gt;in&amp;lt;/b&amp;gt; explist &amp;lt;b&amp;gt;do&amp;lt;/b&amp;gt; block end&lt;br /&gt;
is equivalent to (Full explanation [https://www.lua.org/pil/7.2.html here].)&lt;br /&gt;
 do&lt;br /&gt;
   local _f, _s, _var = explist&lt;br /&gt;
   while true do&lt;br /&gt;
     local var_1, ... , var_n = _f(_s, _var)&lt;br /&gt;
     _var = var_1&lt;br /&gt;
     if _var == nil then break end&lt;br /&gt;
     block&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Iterator closure that holds its state&lt;br /&gt;
 function iter(a)&lt;br /&gt;
   local i = 0&lt;br /&gt;
   return function()&lt;br /&gt;
     i = i+1&lt;br /&gt;
     return a[i]&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 local arr = {2,3,7,5}&lt;br /&gt;
 for value in iter(arr) do&lt;br /&gt;
   logf(&amp;quot;%d&amp;quot;,value)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Stateless iterator (in this case returns variable list: key and value)&lt;br /&gt;
 function iter(a,i)&lt;br /&gt;
   i = i+1&lt;br /&gt;
   if a[i] then return i,a[i] end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 local arr = {2,3,7,5}&lt;br /&gt;
 for k,v in iter,arr,0 do&lt;br /&gt;
   logf(&amp;quot;%d:%d&amp;quot;,k,v)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Same effect using &amp;lt;code&amp;gt;ipairs()&amp;lt;/code&amp;gt; Lua function (without initial state)&lt;br /&gt;
 for k,v in ipairs(arr) do&lt;br /&gt;
   logf(&amp;quot;%d:%d&amp;quot;,k,v)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Now return to the most common example above using &amp;lt;code&amp;gt;pairs()&amp;lt;/code&amp;gt; Lua function and read about &amp;lt;code&amp;gt;pairs()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;ipairs()&amp;lt;/code&amp;gt; implementation [https://www.lua.org/pil/7.3.html here].&lt;/div&gt;</summary>
		<author><name>Jturon</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.netio-products.com/index.php?title=Welcome_to_NETIO_resources_%26_projects_%26_documentation_overview&amp;diff=312</id>
		<title>Welcome to NETIO resources &amp; projects &amp; documentation overview</title>
		<link rel="alternate" type="text/html" href="https://wiki.netio-products.com/index.php?title=Welcome_to_NETIO_resources_%26_projects_%26_documentation_overview&amp;diff=312"/>
		<updated>2017-04-25T09:02:23Z</updated>

		<summary type="html">&lt;p&gt;Jturon: /* Netio Programming */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Netio Programming ==&lt;br /&gt;
Netio uses Lua as its scripting language. To master it, follow these references:&lt;br /&gt;
* [https://www.lua.org/pil/contents.html Lua tutorial] - If you are new to Lua and programming as such and if you are eager to learn, this is your starting point. Before you proceed to Netio Sockets, this [https://www.lua.org/demo.html online environment] will be a good place to test your first scripts.&lt;br /&gt;
* [[Netio Lua Manual]] - A quick jump into Netio Lua programming if you mastered another programming language. If you already know Lua, just keep in mind that Netio Lua loops are limited to 32k cycles and all numbers are integers, not decimals like in standard Lua.&lt;br /&gt;
* [[Netio Lua Reference]] - If you can already code in Lua, Netio-specific Lua functions is your main guide to programm Netio Sockets.&lt;br /&gt;
* [https://www.lua.org/manual/5.3/ Lua manual] - Although you won't need everything mentioned here, it is worth to peek here from time to time to grasp the concepts of effective Lua programming.&lt;/div&gt;</summary>
		<author><name>Jturon</name></author>
		
	</entry>
</feed>